在SQL SELECT CASE STATEMENT中如何检查sometable中某些coulmn的值是否等于0,其中id等于某事?
答案 0 :(得分:3)
select
case
when (select column_name from sometable where id = @id) = 0 then
else
end
答案 1 :(得分:2)
select
case when( select column from table where id=333)=0 then "your condition"
else
end
答案 2 :(得分:1)
我对你的问题的解释:
当id = 333时,SQL检查字段(Field1)的数值是否为0 [仅] [如果id不是333,则不需要检查]
SELECT CASE WHEN isnull(id,0) <> 333 OR Field1=0 THEN 1 ELSE 0 END
,other1, other2
FROM tbl