更改名称结果查询

时间:2019-01-17 03:56:33

标签: mysql

我尝试了此查询

[^%&\\\'+"]

结果为select count(id) as id_name, category as media from tb_gadar where d BETWEEN '2018-04-01' and '2019-12-31' and category in ('Laki-laki','Perempuan')`

如何将144, Laki-laki更改为Laki-laki

1 个答案:

答案 0 :(得分:2)

您可以使用CASE语句来完成

select count(id) as id_name, 
       case when category = 'Laki-laki'  then 'Umum' else category end as media  
from tb_gadar
where d BETWEEN '2018-04-01' and '2019-12-31'
and category in ('Laki-laki','Perempuan')
group by category