如何在case语句中使用条件:
select * from tbl
where case when expr then
(
(x=@_megacity and state_group in (select * from temp_state_megacity)) OR
(x=@_10lac and state_group in (select * from temp_state_10lac)) OR
(x=@_below10 and state_group in (select * from temp_state_below10)) OR
(x=@_rural and state_group in (select * from temp_state_rural))
) else true end
错误-语法不正确
在WHERE
条款使用AND
,OR
并NOT
以表达式组合:
select * from tbl
where NOT <expression> OR
(
(x=@_megacity and state_group in (select * from temp_state_megacity)) OR
(x=@_10lac and state_group in (select * from temp_state_10lac)) OR
(x=@_below10 and state_group in (select * from temp_state_below10)) OR
(x=@_rural and state_group in (select * from temp_state_rural))
);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句