在mysql腳本中,case when then 是對(duì)列的枚舉進(jìn)行翻譯為可讀性好的文字
例如:性別這列 1 代表男? 2代表女
case when xingbie='1' then '男'
when xingbie='2' then '女' end as 性別
--tips: 我們知道這列的枚舉值是什么,并可以對(duì)枚舉值一一翻譯,超過(guò)10個(gè)以上就不建議使用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/