Chat table
id from_id to_id message time 1 1 3 Привет 05.01.2017 20:00 2 2 1 Здраствуй 05.01.2017 21:00 3 3 1 Привет! 05.01.2017 22:00 Table users
id name 1 Алексей 2 Дмитрий 3 Ольга I want to withdraw in the account of Alexei likeness:
3 Ольга: Послднее сообщение 05.01.2017 22:00 2 Дмитрий: Послднее сообщение 05.01.2017 21:00 From patients who stupidly minus the question, there is no sense ..
I figured it out myself:
SELECT DISTINCT to, MAX(time) FROM CHAT where from = '"1"' GROUP BY to ORDER BY MAX(time) DESC) We receive a new message list without repeating the distance, you can already display it with names.
