+
95
-

回答

SELECT * FROM (SELECT *,receiveid as chatuid FROM message WHERE (sendid = 1) AND (receiveid <> 1) UNION SELECT *,sendid as chatuid FROM message WHERE (sendid <> 1) AND (receiveid  = 1) ORDER BY sendtime DESC) as table1 GROUP BY table1.chatuid ORDER BY table1.sendtime DESC

1表示当前用户的id,chatuid表示聊天对象的uid

网友回复

我知道答案,我要回答