接着问:如何将一个表中的5条记录,union到别一个表的任意的5条记录? 即10条记录中有5条是固有的,另外5条则是随机的,但现在需要用union放在一起,怎么做?这样:select top 5 id,username,newid() from table1 union select top 5 id,username,newid() from table1 order by Newid 是不行的,不能取出随机的数
select top 5 id,username,newid() as newid from table1 union select * from ( select top 5 id,username,newid() as newid from table1 order by newid()) a order by Newid
select top 10 * from (select * from yourtable1 union all select * from yourtable2 t1 ) t2 order by newid()
即10条记录中有5条是固有的,另外5条则是随机的,但现在需要用union放在一起,怎么做?这样:select top 5 id,username,newid() from table1
union
select top 5 id,username,newid() from table1 order by Newid
是不行的,不能取出随机的数
union
select * from (
select top 5 id,username,newid() as newid from table1 order by newid()) a order by Newid
(select * from yourtable1
union all
select * from yourtable2 t1 ) t2
order by newid()
特别是j9988,
现在我把分都给出了,---我要向 j9988(j9988) 学习~~~~