Query returns additional rows

后端 未结 4 1133
无人及你
无人及你 2021-01-20 15:49

I have this kind of table for simple chat:

messages table structure
+----+---------+-----------+---------+------+------+
| id | to_user | from_user | message         


        
4条回答
  •  温柔的废话
    2021-01-20 16:27

    You are getting the last message from each user because you have done GROUP BY for both: to_user and from_user.

    There is no need to use GROUP BY clause in your query.

提交回复
热议问题