1.ifnull(col2=0,'xxx')
col2 is null 则返回 'xxx'
col2 is not null 则返回 1
2.ifnull(col2=1,'xxx')
col2 is null 则返回 'xxx'
col2 is not null 则返回 0
1.=0时
select ifnull(null=0,'xxx'); 输出 'xxx'
select ifnull('aaa'=0,'xxx'); 输出 1
2.=1时
select ifnull(null=1,'xxx'); 输出 'xxx'
select ifnull('aaa'=1,'xxx'); 输出 0
网友评论