我有一个 PHP 消息传递系统,其工作方式如下。
message_thread 表 id(pk)、user1_deleted、user2_deleted
消息 id,thread_id(fk),消息,message_date,sender_id,receiver_id,sender_deleted,receiver_deleted
我试图通过使用以下命令查询消息表来获取包含最后一条消息的线程列表
$sql = "SELECT thread_id, msg, sender_id, receiver_id, MAX(message_date) AS msg_date FROM messages WHERE (sender_id = '$user_id' AND sender_deleted = 0) OR (receiver_id = '$user_id' AND receiver_deleted = 0) GROUP BY thread_id.
这有效,但不显示最后一条消息。它只显示第一条消息。
有谁知道可能出了什么问题?
谢谢