Answer the question
In order to leave comments, you need to log in
How to get latest message via join?
I have a query with which I get the friends of a certain user. But I also want to get the last message between these users, but when I try to get messages via inner join I get all the messages. How to get only the latest?
Current request:
SELECT * FROM `friends` INNER JOIN `users` ON users.id = friends.`id_one` OR users.id = friends.`id_two` WHERE (friends.`id_one` = 1 OR friends.`id_two` = 1) AND `users`.id != 1 AND friends.status = 'friend'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question