—— 阿尔伯特·爱因斯坦

程序员の奇妙冒险

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

MySQL逗号分割字段的列转行

1
2
3
4
5
6
7
8
9
10
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)
暂无评论来抢沙发吧~