MySQL中将一列以逗号分隔的值行转列
2020-04-09 17:24阅读:
sky9
Hello,我是一名互联网后台开发工程师,正在升级打怪。
关注
$sql = 'select
a.*,substring_index(substring_index(a.col,',',b.help_topic_id+1),',',-1)
order_id,o.store_code,o.goods_no,o.goods_size1,o.picking_supplier,t.original_name,t.tel,t.address,t.shop_name,t.taobao_username
from
(select *,order_id col from tianma_wms_line.l_refuse_pic) as
a
join
mysql.help_topic as b
on b.help_topic_id < (char_length(a.col) -
char_length(replace(a.col,',',''))+1)
left join tianma_wms_line.l_orders o on
o.other_order_id=substring_index(substring_index(a.col,',',b.help_topic_id+1),',',-1)
left join tianma_wms_line.l_trades t on o.trade_id=t.id
{$where}';
https://blog.csdn.net/github_33809414/article/details/86656216