I am trying to build a query that returns the most recent message from two joined tables. But I am getting an error on group by. Maybe I am approaching it the wrong completely.
I know that in my current implementation I will get a list, and not the most recent, but I at least want to see the most recent at the beginning
SELECT m.message, m.created_at
FROM conversations c
JOIN messages m ON c.id = m.conversation_id
WHERE m.conversation_id = 5
GROUP BY m.created_at DESC;
Here's the error: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'tawkifydb.dm.message' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by