我将加入三个表chat,users,messages,然后使用GROUP BY将它们分组以获取相似行的一个数据,然后成功将其激发。但是现在我想按时间排序消息。我尝试按时间使用订单,但没有得到想要的结果。我试过的查询是->
SELECT
m.*,c.*, s.uname as sender_name, r.uname as receiver_name,s.phone as
sender_phone, r.phone as receiver_phone FROM message m
JOIN chat c on c.mid = m.mid
JOIN users s on s.uid = c.sender
JOIN users r on r.uid = c.receiver
WHERE c.sender = '1' or c.receiver = '1'
group by IF(c.sender > c.receiver, c.sender,c.receiver),
IF(c.sender > c.receiver, c.receiver,c.sender)
order by m.time