sql 条件判断
select id, if(sex = 1, '男', if(sex=0 , '未知' , '女')) 性别 from user
相当于
select id, case when sex = 1 then '男' when sex = 2 then '女' when sex = 0 then '未知' end from user
select id, if(sex = 1, '男', if(sex=0 , '未知' , '女')) 性别 from user
相当于
select id, case when sex = 1 then '男' when sex = 2 then '女' when sex = 0 then '未知' end from user