首页 > 解决方案 > WHERE 子句中的 CASE 表达式用于不同和

问题描述

我可以使用 case 表达式来构建这样的位置吗?

select * 
from table 
where
case 
    when x=y then z= j and t=v
    when x=k then q= p and s=l
end
;

我需要根据 x 变量的值更改 where 子句。

标签: sqloracle

解决方案


使用or

select * 
from table 
where (x = y and z = j and t = v) or (x = k and q = p and s = l);

推荐阅读