select id,newid() from dizigui where id = 342
union
select top 3 id,newid() from dizigui where id != 341 and id != 342 order by checksum(newid())
------其他解决方案-------------------- select Pid from Product where pid=20
union
select PID from (select top 3 PID,NEWID() as a from Product order by checksum(newid()))A
sql 2000 中有这个函数
但是提示 “如果语句中包含 UNION 运算符,那么 ORDER BY 子句中的项就必须出现在选择列表中。”
换成这样
select id,checksum(newid()) from dizigui where id = 342
union
select top 3 id,checksum(newid()) from dizigui where id != 341 and id != 342 order by checksum(newid())