I have a table structure like this:
Comments table
id review_id user_id created comments deleted
1 10 28 2011-10-12 "hi" 0
2 11 28 2011-10-13 "yo" 0
3 10 28 2011-10-15 "bye" 0
I want to get the latest comment from each review sorted by created DESC. So I have something like this:
SELECT DISTINCT review_id, 'comments' as type FROM comments as MyTable WHERE
user_id=28 AND deleted=0 ORDER BY created DESC LIMIT 30
So in the above table I want the rows for id = 3 and then id = 2 returned.
Example Query:
https://data.stackexchange.com/stackoverflow/s/2143/getting-distinct-ids-in-mysql