I’m having a problem with the order of my query with a group by.
I have a table download_category and download. The download table has a column named “thumb” (it’s a image – varchar). I want to get name of category and the last thumb inserted.
I’m doing this way:
SELECT download_category.id
, download_category.link
, download.thumb
FROM download
RIGHT JOIN download_category ON (download_category.id = download.idCategoria )
WHERE download_category.link IN ('link-of-category')
GROUP BY download_category.id
, download_category.link
ORDER BY download.id DESC
The RIGHT JOIN is necessary in case of not exists a download.
The problem is: the thumb columns is returning the first inserted record, instead the last “download.id DESC”. What am I doing wrong?
Try this: