我有三个表:对话、消息和用户。
表的解释是here。对话表:
id
user1
user2
消息表:
id
conversation_id
fromUser
toUser
is_read
用户表:
id
name
etc
现在,我想获取特定用户 ID 的对话,假设为 210. 并且带有未读消息的对话应该放在最前面。
任何帮助将不胜感激。
编辑:我现在触发的查询是:
SELECT * FROM `messages`
join conversations on messages.conversation_id = conversations.id
where messages.fromUser = 210 or messages.toUser = 210
GROUP by messages.conversation_id
ORDER by messages.is_read ASC, messages.id DESC
我得到的结果:https : //i.stack.imgur.com/NEeMs.png
基于预期结果的对话 ID:
2
8
1724
and then others.
动漫人物
白板的微信