mysql IF语句使用

类似于三元运算符

1)  IF(where,result1,result2) = where?result1:result2

例如 SELECT IF(1=1,1,2)    =>  1 

 

2)  IFNULL(result1,result2) = result1 is not null?result1:result2

例如 SELECT IF(1,2)  => 1  

  SELECT IF(null,2) => 2

posted on 2017-11-23 09:53  彩洋威  阅读(12600)  评论(1编辑  收藏  举报

导航