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

posted @ 2022-03-24 22:54  zhoudingzhao  阅读(111)  评论(0编辑  收藏  举报