case when a=null then a=0 else a则不变,仍旧是原先的a的值

2025-02-24 04:49:40
推荐回答(1个)
回答1:

null值要用IS NULL判断,不能用“=”。select case when a is null then '0' else a end as a from 表名。0如果是数值型,可以直接写0,不加引号。null 跟''不一样,如果有''值,需要在条件写case when a is null or a=''。