Php 按用户名获取对话的最后消息
Plis帮助,获取最后消息对话 数据库:Php 按用户名获取对话的最后消息,php,mysql,Php,Mysql,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
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