I have a table with user comments in a guestbook. Columns are: id, user_id, title, comment, timestamp.
I need to select the latest row for each user.
I have tried to do this with group by but havent managed it because i cant select anything else in the same query where i group by user_id:
SELECT user_id, MAX(ts) FROM comments GROUP BY user_id
for example in this query i cant add to also select columns id, tilte and comment. How can this be done?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…