mysql case when多条件同时满足的多个and组合嵌套的情况，判断空is null --- 系列一 https://blog.csdn.net/qb170217/article/details/81504578

``````SELECT id, time, type,
CASE when (reason is null or reason = '') and type = '驳回' THEN '未填写驳回理由'
ELSE reason
END reason
from workFlow
order by time desc; ``````

``````SELECT id,time,type,
CASE when type = '驳回' and (reason is null or reason = '') THEN '未填写驳回理由'
ELSE reason
END reason
from workFlow
order by time desc;``````

``````SELECT id,time,type,
CASE when type = '驳回' and reason is null or reason = '' THEN '未填写驳回理由'
ELSE reason
END reason
from workFlow
order by time desc;``````

``````SELECT id,time,type,
CASE when (type = '驳回' and reason is null) or reason = '' THEN '未填写驳回理由'
ELSE reason
END reason
from workFlow
order by time desc;``````

在我预想的是两种结果组合：条件1：type='驳回' and reason is null,  条件2： 单独的 reason='', 而实际结果与我预想的不一样。

个人觉得， 1和2一样结果，3和4是另一个一样的结果，但与实际测试结果不一样。事实上，上面4种方法一样的结果。还得继续努力呀！

``````SELECT id,time,type,
CASE when reason = '' or reason  is null and type = '驳回' THEN '未填写驳回理由'
ELSE reason
END reason
from workFlow
order by time desc;``````

``````SELECT id,time,type,
CASE when reason is null or reason = '' and type = '驳回'  THEN '未填写驳回理由'
ELSE reason
END reason
from workFlow
order by time desc;``````