说明 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'
转载于:https://www.cnblogs.com/zhangjian816/p/10556681.html