关于null或者其他内容的替换如何实现?2019-06-25
2019-06-28 本文已影响0人
可乐要坚持学习
![](https://img.haomeiwen.com/i15895381/5c75ac04f7f7078b.png)
![](https://img.haomeiwen.com/i15895381/ad1b6a6d0b942899.png)
![](https://img.haomeiwen.com/i15895381/4ecc4808c6cb66d3.png)
当要查询的某字段下的记录为空时,替换为0或“无”或“未知”如何实现?
使用 (case when ````` is null then "无" else ````` end) as ``````
延伸疑问:如果是1、2、3、4 ,要替换为A、B、C、D的话,
case when id=1 then 'A'
when id=2 then 'B'
when id=3 then 'C'
when id=4 then 'D'
else '其他' end
![](https://img.haomeiwen.com/i15895381/0d388dcf6b5caf06.jpg)