select case when user_name = '四狗' then '我' else '别人' end from sys_user
select case user_name when '四狗' then '我' else '别人' end from sys_user
将符合 case when 条件的数据,赋值为 then 后面的
将不符合 case when 条件的数据,赋值为 else 后面的
user_name = '四狗'? '我' : ‘别人’
if(user_name = '四狗') {
user_name = '我'
} else {
user_name = '别人'
}
本文详细介绍了SQL中Case When语句的使用方法,包括如何根据不同的条件为查询结果赋值,通过具体示例展示了当条件满足时赋值为特定值,不满足时赋值为另一值的过程。
2504

被折叠的 条评论
为什么被折叠?



