(case '字段'

when '数据1' then '输出1'

when '数据2' then '输出2'

when '数据3' then '输出3'

else '其他数据输出一致'

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;

原始数据查询:

case函数,replace函数-LMLPHP

修改后查询:

case函数,replace函数-LMLPHP

05-26 21:31