程序员の奇妙冒险

返回
常用SQL笔记 MySQL
2025-04-08 23:43 阅读:66 评论:0

MySQL逗号分割字段的列转行

1
2
3
4
5
6
7
8
9
select a.id,substring_index(substring_index(a.val,',',b.help_topic_id+1),',',-1)
from
tbl_brand_attr_group a
join
mysql.help_topic b
on b.help_topic_id < (length(a.val) - length(replace(a.val,',',''))+1)
#
and a.id='e0e00b82-e148-4918-8e5d-f167a5a8006d'
order by a.id;
评论 (0)
暂无评论 来抢沙发吧~