
[英]Get conversations and messages. The conversation with last unread message should be on top
[英]get last messages conversation by username
Plis帮助,获取最新消息对话!!
数据库:
id,
user_from
user_to
msg
查询PHP
select *
from messages
where
user_from = 'Michael' AND
user_to = 'Daiana' OR
user_from = 'Daiana' AND
user_to = 'Michael'
LEAST(user_to _id, user_from)
order by id desc
limit 1
请帮我。 例如,他没有在Daiana和Michael两个用户的对话中列出最新消息。
示例结果:
select *
from messages
where
(user_from = 'Michael' AND user_to = 'Daiana')
OR
(user_from = 'Daiana' AND user_to = 'Michael' )
LEAST(user_to _id, user_from)
order by id desc
limit 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.