62,047
社区成员
发帖
与我相关
我的任务
分享
create procedure GetNewMsg
@username varchar(50)
as
--获取用户已经列出的消息id最大值
declare @last int
set @last=(select lastchatinfo from UserInfo where username=@username)
--获取最新的消息列表
select id,user_from,user_to,[content],expression,color,ispublic,sendtime from ChatInfo
where(id>@last)and((ispublic=1)or(user_to=@username)or(user_from=@username)
or(user_to='大家')and(sendtime>getdate()-'00:05:00')order by sendtime desc