update testtop set updatedate=i.updatedate from testtop t join inserted i on t.username=i.username where updatedate=(select max(updatedate) from testtop t1 where t1.username=t.username)
declare @i int,@n varchar(100),@d varchar(100) select @n=username, @d=updatedate from inserted select @i=max(id) from testtop where username=@n update testtop set updatedate=@d where id=@i
我要实现的查询是,找出最近一条username=AA的记录,也就是ID=5的那一条!------------------- select top 1 from (select * from 表 where username='aa' order by id desc) b
该为下面的形式 update testtop set updatedate=(select updatedate from inserted) where [id]=(select max([id]) from testtop where username=(select username from inserted))
select @n=username, @d=updatedate from inserted
select @i=max(id) from testtop where username=@n
update testtop set updatedate=@d where id=@i
select top 1 from (select * from 表 where username='aa' order by id desc) b
update testtop set updatedate=(select updatedate from inserted)
where [id]=(select max([id]) from testtop where username=(select username from inserted))