日期:2014-05-17 浏览次数:20660 次
--首先你要保证符合G_ID =0 AND is_manager = 1的记录有三条或三条以上,改为下面则一定更新随机的三条 UPDATE BaseUser SET G_ID = 10 WHERE G_ID =0 AND is_manager = 1 AND ID IN(select top 3 ID from BaseUser G_ID =0 AND is_manager = 1 order by newid()) /*按你之前写的,即使有三条以上,但符合G_ID =0 AND is_manager = 1的ID 却不一定在select top 3 ID from BaseUser order by newid())这个范围内*/
------解决方案--------------------
select * from BaseUser WHERE G_ID =0 AND is_manager = 1
AND ID IN(select top 3 ID from BaseUser order by newid())
你查一下这个每次能查出多少条数据,就知道问题所在啦