SQL多個條件查詢語句
Declare @DLBM nvarchar(255),@DLMC nvarchar(255)
set @DLBM='查詢內容'
set @DLMC='查詢內容'
select * from 表名稱 where DLBM=@DLBM and len(@DLBM)>0
union
select * from 表名稱 where DLMC=@DLMC and len(@DLMC)>0
。。.拼接全部條件
sql 語句where 有多個條件,怎樣查出其中滿足3個以上的
select * from table
where (
case when c2 > 1 then 1 else 0 end +
case when c3 > 2 then 1 else 0 end +
case when c4 > 1 then 1 else 0 end +
case when c5 > 1 then 1 else 0 end +
case when c6 > 1 then 1 else 0 end ) >= 3
sql語句怎么樣一次性查詢多個條件,并分列顯示
方法一,分別查詢出來,結果再關聯
select fnum1,fnum2 from
(select count(*) as fnum1 from 表名 where a=2 and b=3) t1,
(select count(*) as fnum2 from 表名 where a=3 and b=5) t2方法二
select sum(case when a = 2 and b = 3 then 1 else 0 end) as fnum1,
sum(case when a = 3 and b = 5 then 1 else 0 end) as fnum2
from 表名
where a = 2 and b = 3
or a = 3 and b = 5有問題請追問