日期:2014-05-17 浏览次数:20543 次
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'))
/*
a b c
-----------------------------------
10 bb mm
*/
select *
from tb
where a>1 and b in('cc','dd','bb','mm') and c in('cc','dd','bb','mm')