码迷,mamicode.com
首页 > 其他好文 > 详细

两个表联合查询获取聊天表中用户最新的一条聊天数据

时间:2017-03-27 22:19:37      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:用户表   聊天记录   where   sel   聊天   获取   esc   order   user   

 
一个用户表,一个聊天记录表,两个表联合查询获取聊天表中用户最新的一条聊天数据
select c.content
from sixin as c where c.tid = a.user_id
order by ctime desc limit 0,1
) as content,
(
select c.status
from sixin as c where c.tid = a.user_id
order by ctime desc limit 0,1
) as status

from users as a, sixin as b where a.user_id = b.tid group by a.user_id

两个表联合查询获取聊天表中用户最新的一条聊天数据

标签:用户表   聊天记录   where   sel   聊天   获取   esc   order   user   

原文地址:http://www.cnblogs.com/myphper/p/6628434.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!