解决办法,使用临时表:
第一步:创建临时表,并将in内的数据插入到表中
select * into # from (
select '1' num union all
select '2' union all
select '3' union all
.....
select 'N'
) a
第二步:执行in查询
select * from 表 where 列 in(select num from #)
第三步:销毁临时表
drop table #
若是连起来写:
set nocount on;select * into # from (select '1' num union all select '2' union all select '3' union all ..... select 'N') a;select * from 表 where 列 in(select num from #);drop table #
那就使用 not in 后面的集合不就会减少