where后条件判定 抛弃casewhen

SELECT * FROM sys_user su WHERE 其他条件 and

not exists (条件A) or 条件B;

如果条件A成立则执行条件B,如果条件A不成立则不执行条件B

SELECT * FROM sys_user su WHERE su.CREATED_BY =21 and

not exists ( select 1 from sys_role sr where sr.role_code in ('0006') and sr.role_id = 10000025) or su.USER_NAME='DSB';

posted @ 2022-11-16 17:45  少昊  阅读(48)  评论(0)    收藏  举报