水货求sql
table
a b c
1 cc dd
10 bb mm
查询出 a>1 b,c 的值 在 cc , dd , bb , mm中的记录
[解决办法]
SELECT *
FROM dbo.tablename
WHERE a > 1
AND (b IN('cc', 'dd', 'bb', 'mm') OR c IN('cc', 'dd', 'bb', 'mm'))
create table #tb(a int,b varchar(10),c varchar(10))
insert into #tb
select 1,'cc','dd'
union all select 10,'bb','mm'
union all select 15,'xx','ww'
select *
from #tb
where a>1 and (b in('cc','dd','bb','mm') or c in('cc','dd','bb','mm'))
/*
abc
-----------------------------------
10bbmm
*/
select *
from tb
where a>1 and b in('cc','dd','bb','mm') and c in('cc','dd','bb','mm')