I want to display the last message from each user. I wrote this MySQL request but it displays the last message from one user, and the first messages from other users. I don't understand why.
SELECT *
FROM cbadminmessages
INNER JOIN cbmembres ON cbadminmessages.id_membre_message=cbmembres.id
WHERE id!='$admin_id'
AND id_message IN(
SELECT MAX(id_message)
FROM cbadminmessages
GROUP BY id_membre_message)
ORDER BY id_message");
id_message
is the message's id.
id_membre_message
is the member's ID who wrote the message.
Thank you.