I am trying to return back the latest message based on timestamp from a group of Senders.
The basic table and qry looks like this
SELECT senderName, messages
FROM MessageTable
WHERE receiverID = 1
(output)
Joe "Hey"
Bob "Yo"
Jim "Blah"
Joe "What's up"
I want to get the latest message from EACH sender. I thought to use ORDER BY and LIMIT but it just returns 1 message from the entire qry. Which is not the result Iām looking for.
SELECT senderName, messages
FROM MessageTable
WHERE receiverID = 1
ORDER BY sentDate ASC LIMIT 1
(output)
Bob "Yo"
I would like to have this kind of output, where only Joe's latest message is returned along with the other Sender's latest message.
Bob "Yo"
Jim "Blah"
Joe "What's up"
I've looked at another question on stackoverflow, but it didn't make sense to me. https://stackoverflow.com/questions/384142/how-to-get-latest-record-for-each-day-when-there-are-multiple-entries-per-day
Thank you!