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两个用户的对话中列出最新消息。

示例结果:

  • 戴安娜:你好,你好吗
  • 迈克尔:很好,你呢?
  • daiana:很好:)

===============>>#1 票数:0

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

  ask by Guilherme S. Mendes translate from so

未解决问题?本站智能推荐: