各位大师好:
我想请问一个问题:
字段A
11
22
33怎么能得到这样的结果:
select * from 表 where a in (11,22,33,44,55) 结果为空,就是没有数据。
意思是当IN 的里面包含了字段A数值以外的数值 就判断 得到空结果,谢谢指导。
我想请问一个问题:
字段A
11
22
33怎么能得到这样的结果:
select * from 表 where a in (11,22,33,44,55) 结果为空,就是没有数据。
意思是当IN 的里面包含了字段A数值以外的数值 就判断 得到空结果,谢谢指导。
select * from 表 where a in (11,22,33,44,55) 结果为空,就是没有数据。
意思是当IN 的里面包含了字段A数值以外的数值 就判断 得到空结果,谢谢指导。 IN的里面的东西不在表字段里面?什么逻辑?
select * from 表 where
exists(select * from 表 where a not in (11,22,33,44,55) )
select * from ff where
exists(select * from ff where a not in (11,22,33))
这样还是返回为空啊
declare @t table(ColA int)
insert into @t select 11
insert into @t select 22
insert into @t select 33 select
t.*
from
@t t
where
t.ColA in(11,33)
and
exists(select * from @t where ColA in(11,33) having count(distinct ColA)=(len('11,33')-len(replace('11,33',',',''))+1))
/*
ColA
-----------
11
33
*/select
t.*
from
@t t
where
t.ColA in(11,22,33)
and
exists(select * from @t where ColA in(11,22,33) having count(distinct ColA)=(len('11,22,33')-len(replace('11,22,33',',',''))+1))
/*
ColA
-----------
11
22
33
*/select
t.*
from
@t t
where
t.ColA in(11,22,33,44)
and
exists(select * from @t where ColA in(11,22,33,44) having count(distinct ColA)=(len('11,22,33,44')-len(replace('11,22,33,44',',',''))+1))
/*
ColA
-----------
*/
select *
from ta
where charindex(','+ltrim(cola)+',',',11,22,33,44,55,') =0
来个简单的select * from 表 where charindex(','+a+',',','+'11,22,33,44,55'+',')> 0
declare @t table(ColA int)
insert into @t select 11
insert into @t select 22
insert into @t select 33
insert into @t select 88
select * from @t where charindex(','+cast(ColA as nvarchar(10))+',',','+'11,22,33,44,55'+',')> 0 ColA
-----------
11
22
33(3 row(s) affected)