I made a post 6 days ago but no one seemed to anwser correctly and it was eventually abandoned so here I post it again (sorry for DPing but this is important to me) I have 2 tables - people (query is based on people.id so no need to ss the entire table) and messages (http://prntscr.com/94iq2e)
I have a query which is grouping messages with people and that is working fine but each person is grouped with the first message he sent and I need to make it so that it groups people with the LAST message they sent
Here is the query which is grouping people with the FIRST message
SELECT people.id,
people.avatar,
people.firstname,
people.lastname,
LEFT(messages.message, 90) AS message,
messages.seen,
messages.date
FROM people
INNER JOIN messages
ON people.id = messages.sender_id
WHERE reciever_id = '". $user_data['id'] ."'
GROUP BY sender_id
ORDER BY date DESC limit 11
Link to the previous topic -> Selecting last record from INNER JOIN and grouping