SQL语句 用union时的问题

来源:百度知道 编辑:UC知道 时间:2024/06/08 00:30:44
select top 2 * into a2 from tb_Questions where que_type='单选题' order by newid()
union
select top 1 * from tb_Questions where que_type='多选题' order by newid()
上面这个SQL语句怎么改才正确,我想实现随即抽取。

------修改----------------------
select * into a2 from
(select * from (select top 2 * from tb_Questions where que_type='单选题' order by newid()) A
union
select * from (select top 1 * from tb_Questions where que_type='多选题' order by newid()) B) T

前提是这张表里的字段不包含text、ntext、image类型的

select * from(
select top 2 * into a2 from tb_Questions where que_type='单选题'
union
select top 1 * from tb_Questions where que_type='多选题')order by newid()

select top 2 * from tb_Questions where que_type='单选题' order by newid()
union
select top 1 * from tb_Questions where que_type='多选题' order by newid()

---into a2 这个事啥子玩意

select * from(
select top 2 * into a2 from tb_Questions where que_type='单选题'
union
select top 1 * from tb_Questions where que_type='多选题')order by newid()
把所有的条件都写在from里面就可以了