【发布时间】:2013-09-09 08:14:24
【问题描述】:
我有两个人用户 222 和用户 5555 之间的消息对话,显示如下:
Conversation-ID 1, Message-ID 5, User-ID 222: "Oh, and I'm happy about that!"
Conversation-ID 1, Message-ID 4, User-ID 222: "And bought me a new car."
Conversation-ID 1, Message-ID 3, User-ID 222: "I just won some money!"
Conversation-ID 1, Message-ID 2, User-ID 5555: "Fine, how are you?"
Conversation-ID 1, Message-ID 1, User-ID 222: "Hi there, how are you?"
现在我正在寻找 PHP / MySQL 中的解决方案,以仅显示来自 User-ID 222 的消息,直到来自 User-ID 5555 的消息。
结果应该是:
Conversation-ID 1, Message-ID 5, User-ID 222: "Oh, and I'm happy about that!"
Conversation-ID 1, Message-ID 4, User-ID 222: "And bought me a new car."
Conversation-ID 1, Message-ID 3, User-ID 222: "I just won some money!"
其实我有
"SELECT * FROM table_conversations WHERE conversation_id='1' and user_id !='5555' ORDER BY message_id DESC"
但这当然会显示来自 User-ID 222 的所有消息。我想要的是只有来自 User-ID 222 的最后未答复的消息。
PHP 和 MySQL 中是否有任何命令或解决方案可以得到这个结果,也适用于所有其他对话?
【问题讨论】: