查询聊天消息SQL语句!

select top 10 f.Name as 'Formusername',t.Name as 'ToUsername',m.id,m.Fromuserid,m.TouserId,m.Message,m.recordTime,m.messageState,m.readflag from Message as m
inner join Users as f on f.Id=m.FromUserId
inner join Users as t on t.Id=m.ToUserId
order by recordtime desc

Message 表

image

Users 表

image

inner join 内连接查询,效率高!

发稿地址

地图图片

posted @ 2009-11-05 23:24  王大湿  阅读(310)  评论(0编辑  收藏  举报