两个表联合查询获取聊天表中用户最新的一条聊天数据
Posted 幸福之家128817
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了两个表联合查询获取聊天表中用户最新的一条聊天数据相关的知识,希望对你有一定的参考价值。
一个用户表,一个聊天记录表,两个表联合查询获取聊天表中用户最新的一条聊天数据
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
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
以上是关于两个表联合查询获取聊天表中用户最新的一条聊天数据的主要内容,如果未能解决你的问题,请参考以下文章