嗨,我想在where条件或类似逻辑中使用case语句。
我想忽略tmp_collaboration表中没有行时的where条件,并在表中有行时使用该条件。
Select clbid from tmp_collaboration;
select customer_id, product_id ,clbid
from customers c
where hdr_id = 10
and clbid in (select clbid from tmp_collaboration)
and status = 'y';
最佳答案
这就是你想要的吗?
select customer_id, product_id ,clbid
from customers c
where hdr_id = 10 and status = 'y' and
(clbid in (select clbid from tmp_collaboration) or
not exists (select 1 from tmp_collaboration)
);
关于sql - 加入条件的案例陈述,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52428177/