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