一個用戶表,一個聊天記錄表,兩個表聯合查詢獲取聊天表中用戶最新的一條聊天數據
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
