case函数,replace函数
(case '字段'
when '數(shù)據(jù)1' then '輸出1'
when '數(shù)據(jù)2' then '輸出2'
when '數(shù)據(jù)3' then '輸出3'
else '其他數(shù)據(jù)輸出一致'
end) as '字段'
replace(字段,'原子字符串','新子字符串') as 字段
select username,
(case `role`
when 0 then '班長'
when 1 then '課代表'
when 2 then '組長'
when 3 then '學生'
else '超級管理員'
end) as 'role',
replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(
replace(replace(replace(replace(replace(replace(user_condition,'10','語文j'),
'11','語文k'),'12','語文l'),'13','語文m'),'14','語文n'),'15','語文o'),'16','語文p'),'1','語文a'),
'2','語文b'),'3','語文c'),'4','語文d'),'5','語文e'),'6','語文f'),'7','語文g'),'8','語文h),'9','語文i')
as user_condition from loginuser a, user_menu b where a.id = b.UserId and region = 999;
?原始數(shù)據(jù)查詢:
?修改后查詢:
?
轉載于:https://www.cnblogs.com/likaixin/p/11264400.html
總結
以上是生活随笔為你收集整理的case函数,replace函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 自我觉察-3:发现-我这么做究竟为了什么
- 下一篇: 10个绕过反病毒的恶意用户技巧