mysql數據庫group_concat函數內包含case when 語法時的使用



select `a`.`tdorderid`,group_concat('類型:',(case `a`.`td_type` when 'no_goods' then '無貨退款' when 'low_quantity' then '質量退款'
when 'no_reason' then '非質量退款' else '無' end),'/退貨員:',(case when`a`.`td_user` is null then '無'
when `a`.`td_user` is not null then `a`.`td_user` end) separator ',') AS `goods1` from `gr_reject_goods` `a` group by `a`.`tdorderid`


在group_concat函數里面使用case when 語法與一般情況無異。

case when 在判斷是否為null的時候要注意,字段 is null ,字段is not null
————————————————
版權聲明:本文為CSDN博主「code旅行者」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/dotNET25/article/details/52610436


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM