一个用户表,一个聊天记录表,两个表联合查询获取聊天表中用户最新的一条聊天数据
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
http://www.ink520.com/