so i've got two tables:
photos:
id | url
1 | 1.jpg
2 | 2.jpg
3 | 3.jpg
comments:
picture | date | comment
1 | date | text
2 | date | text
2 | date | text
2 | date | text
etc
I have this query so far:
SELECT a.picture, b.name as picturename, b.url
FROM photo_comments a, photos b
WHERE b.id=a.picture
GROUP BY a.picture
ORDER BY a.date DESC
LIMIT 5
i've tried using the group by clause and i've tried using DISTINCT a.picture, but both times, when you have a picture that has been commented previously and if a user goes to comment on it again, the database uses the oldest comment to order by and not the newest comment. any ideas on how to fix this?