mysql 集合转多行
sql
SELECT
substring_index(substring_index(t1.group_ids, ',', n), ',', -1) AS group_id
FROM (select '908,909' as group_ids ) t1,
(SELECT @rownum := @rownum + 1 AS n FROM ( SELECT @rownum := 0 ) r, orders ) t2
WHERE
n <= ( LENGTH( t1.group_ids ) - LENGTH( REPLACE ( t1.group_ids, ',', '' ) ) + 1 )
注意: 其中orders表的行数必须不能小于 '908,909'集合的数量
参考: mysql使用逗号分隔的一行数据转多行数据