SELECT * FROM `jt_model_files` ORDER by id DESC
SELECT * FROM `jt_model_files` GROUP BY file_id ORDER by id DESC
What i want to achieve is
What is the possible solution.
SELECT * FROM `jt_model_files` ORDER by id DESC
SELECT * FROM `jt_model_files` GROUP BY file_id ORDER by id DESC
What i want to achieve is
What is the possible solution.
SELECT * with GROUP BY is always problematic, even if it is allowed, because the results are undefined.
For your sample data, you should GROUP BY model_id, file_id and get the max value of id:
SELECT MAX(id) AS id, model_id, file_id
FROM jt_model_files
GROUP BY model_id, file_id
ORDER BY MAX(id) DESC