当前位置: 代码迷 >> Sql Server >> select潜套有关问题
  详细解决方案

select潜套有关问题

热度:26   发布时间:2016-04-27 21:07:15.0
select潜套问题
update   test   set   temp= '1 '   where   newid=(select   top   40   *   from   test   order   by   newid())  

当然,上面的语句是错误的,把随机查询到的记录,把temp字段设置成1
请问如何写才正确?

------解决方案--------------------
newid是你表的字段?

如果不是,不能这么用。

假设你表中的字段中有唯一字段ID,则:

update test set temp= '1 '
where ID in (select top 40 ID from test order by newid())
  相关解决方案