I have the following MySQL query :
Select match_static_id, comments as last_comment, max(timestamp)
from comments as c
group by match_static_id;
I have table for comment on matches and i want to have the latest comment of each match. so i use the max(timestamp) and group by (match_static_id) for that but my problem that i get the max timestamp grouped by match_static_id but i get other comment(not the comment of the max timestamp) Is my query ordered in wrong way?
I am not an expert in mysql but I can sense the issue. It could be because the comments in not part of group by, it would return all the rows that match the match_static_id. I would suggest rewriting something like:
or