我有两个人之间的消息对话,用户 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"
但当然这会显示来自用户 ID 222 的所有消息。我想要的只是来自用户 ID 222 的最后未答复的消息。
PHP 和 MySQL 中是否有任何命令或解决方案来获得此结果,也适用于所有其他对话?