mysql生成序列表,生成100个数字,用于拆分字段,一行拆多行

--生产序列表
	create table sequence_table 
						(id int 
						);
						insert into sequence_table
						select @xi:=@xi+1 as xc from 
						(select 1 union select 2 union select 3 union select 4 union select 5) xc1,
						(select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8
						union select 9 union select 10 union select 11 union select 12
						union select 13
						union select 14 union select 15 union select 16 union select 17
						union select 18 union select 19 union select 20 
						
						
						
						) xc2,
						(select @xi:=-1) xc0;
--一行拆分行代码
SELECT 
SUBSTRING_INDEX(SUBSTRING_INDEX(st.product_patent_country,',',a.id+1),',', -1) AS product_patent_country,
esku ,st.saas_id
FROM saas_erp_product_center.tb_product st
JOIN sequence_table a ON a.id <
(LENGTH(st.product_patent_country)-LENGTH(REPLACE(st.product_patent_country,',',''))+1)
where st.is_newest = 1
and st.product_patent_country <>'否'
AND st.delete_time IS NULL 
group by 1,2,3
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值