在mysql脚本中,case when then 是对列的枚举进行翻译为可读性好的文字
例如:性别这列 1 代表男 2代表女
case when xingbie='1' then '男'
when xingbie='2' then '女' end as 性别
--tips: 我们知道这列的枚举值是什么,并可以对枚举值一一翻译,超过10个以上就不建议使用case when then了
--我自己的脚本可以供大家参考
SELECT t.latn_id as XXX,t.CUST_ORDER_ID as XXX,t.upload_state XXX,
case when t.STATUS_CD='101300' then 'XXX'
when t.STATUS_CD='101200' then 'XXX'
when t.STATUS_CD='201700' then 'XXX'
when t.STATUS_CD='201300' then 'XXX'
when t.STATUS_CD='301100' then 'XXX'
else 'XXX'
end as XXX,
t.CREATE_DATE as XXX
FROM customer_order t,
order_attr t1
where t.CUST_ORDER_ID=t1.CUST_ORDER_ID
and t1.ATTR_ID='5050'
and t.CREATE_DATE >= '2021-09-13 08:00:00'
本文摘自 :https://www.cnblogs.com/