如果结果中字段只有id和时间,这么试试:SELECT t1.id, max(t2.时间) FROM user_tbl t1 LEFT JOIN msg_tbl t2 ON t2.id=t1.id GROUP BY t2.id ORDER BY t1.id 如果结果中还需要其它字段(例如,消息内容),请参考: http://expert.csdn.net/Expert/topic/2270/2270426.xml?temp=.6922724
SELECT user.id, msg.time FROM msg RIGHT OUTER JOIN user ON msg.id =user.id order by time desc
SELECT top 1 msg.time FROM user,msg where msg.id =user.id order by msg.time desc
如果结果中字段只有id和时间,这么试试:SELECT t1.id, max(t2.时间) FROM user_tbl t1 LEFT JOIN msg_tbl t2 ON t2.id=t1.id GROUP BY t2.id ORDER BY t1.id 如果结果中还需要其它字段(例如,消息内容),请参考: http://expert.csdn.net/Expert/topic/2270/2270426.xml?temp=.6922724
SELECT t1.user_id, max(t2.time) FROM user t1 left join msgrecord t2 on t1.user_id = t2.sendid group by t1.user_id
如果结果中还需要其它字段(例如,消息内容),请参考:
http://expert.csdn.net/Expert/topic/2270/2270426.xml?temp=.6922724
FROM msg RIGHT OUTER JOIN
user ON msg.id =user.id
order by time desc
FROM user,msg where
msg.id =user.id
order by msg.time desc
如果结果中还需要其它字段(例如,消息内容),请参考:
http://expert.csdn.net/Expert/topic/2270/2270426.xml?temp=.6922724