mysql 逗号分隔成多列数据

说明 t_split  是临时表,分割几个,里面id字段分别是1-5
SELECT
substring_index( substring_index( a.content, ',', b.id + 1 ), ',',- 1 ) product_id
FROM
t_exhibition_booth_cell a
JOIN t_exhibition_booth ON t_exhibition_booth.id = a.booth_id
JOIN t_exhibition ON t_exhibition.id = t_exhibition_booth.exhibition_id
JOIN t_split b ON b.id <= ( length( a.content ) - length( REPLACE ( a.content, ',', '' ) ) + 1 )
WHERE
t_exhibition.CODE = 'homepage5.18'

posted @ 2019-03-19 09:46  黑白配  阅读(1967)  评论(0)    收藏  举报