源码

首页 » 归档 » 源码 » php – mysql查询两个表,检索每个会话的消…

php – mysql查询两个表,检索每个会话的消…


我有两张桌子.

其中一个称为“对话”的数据如下.

ConversationID  Sender     Reciever
1               bla1       bla2
2               bla1       bla3
3               bla1       bla4

另一种称为“消息”的数据如下.

MessageID    MessageText    TimeAddedMessage        ConversationID
1             helo           2012-03-12 13:00:00          2
2             helo           2012-03-12 13:01:00          1
3             helo           2012-03-12 13:02:00          3
4             helo           2012-03-12 13:03:00          3
5             helo           2012-03-12 13:04:00          2

我想从查询中得到的结果如下:

5             helo           2012-03-12 13:04:00          2
4             helo           2012-03-12 13:03:00          3
2             helo           2012-03-12 13:01:00          1

这意味着我们需要每个对话的最新评论(按时间排序DESC).

任何帮助赞赏.

(0)

本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/php-mysqlchaxunlianggebiaojiansuomeigehuihuadexiao.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 12, 2019 at 10:24 下午

热评文章