select * from spzs where gsid in (select id from qyml where hybz=1)
union
select * from spzs where gsid not in (select id from qyml where hybz=1)
order by gsid desc
这样吧,又出现错误提示//不能以 DISTINCT 方式选择 text、ntext 或 image 数据类型。
union
select * from spzs where gsid not in (select id from qyml where hybz=1)
order by gsid desc
这样吧,又出现错误提示//不能以 DISTINCT 方式选择 text、ntext 或 image 数据类型。
union all //为什么要加个all 啊
select * from spzs where gsid not in (select id from qyml where hybz=1)
order by gsid desc
跟上面的union应该没有关系,肯定是你其它地方用了distinct,
union all
我也不清楚
比如:
select 1,2
union all
select 1,2
与
select 1,2
union
select 1,2的区别是, 第一个查询显示2条,后一个查询显示1条。
union all
select * from spzs where gsid not in (select id from qyml where hybz=1)
order by gsid desc我还想问个问题,就是这是显示所有的信息吧,然后满足上面条件的按gsid往前排如果我想选择前10个都在两个条件里面,怎么写啊!
order by gsid desc
select * from #t
union all
select * from spzs where gsid not in (select id from qyml where hybz=1)
select top 10 * from qyml
order by gsid desc