语法:case when 字段名 = '查询到的值' then '要替换的A值' else '要替换的B值' end
示例:
select *,(case when 字段名 = '查询到的值' then '要替换的值' else 字段名 end ) as 字段名 from 表名 where 查询条件
说明:else 语句后的“字段名”表示不符合 when 查询条件的值用原字段的值。
示例:
select *,(case when 字段名 = '查询到的值' then '要替换的值' else 字段名 end ) as 字段名 from 表名 where 查询条件
说明:else 语句后的“字段名”表示不符合 when 查询条件的值用原字段的值。