Search results in a table of private conversations

Asked

Viewed 25 times

0

I would like a help from you because I could not do with the topics I found on the internet.

I have a "Chat" table with the following fields: Estrutura da tabela Chat

And I’m using the following select:

SELECT b.`id`, b.`Fullname`, b.`Photo`, a.`Message`
FROM `Chat` AS a
INNER JOIN `Users` AS b ON b.`id` = a.`SenderBy`
WHERE a.`ReceiverBy` = '2'
GROUP BY a.`SenderBy`
ORDER BY a.`CreateDate`
LIMIT 20

That returns me the following result: resultado da query acima

But the expected should be: inserir a descrição da imagem aqui

Anyway, what I was having done: Select the last messages received by Senderby group in descending order.

  • Tries to change from ORDER BY a.CreateDate for ORDER BY a.CreateDate DESC

  • It didn’t work out like waiting for him either, it just changed that Lucas Soares came in first, which is wrong.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.