数据逗号分隔转多行数据

SELECT

a.字段名B,

substring_index( substring_index( a.col, ',', b.help_topic_id + 1 ), ',',- 1 )

FROM

(

SELECT REPLACE

( REPLACE ( REPLACE ( `字段名A`, '"', '' ), '[', '' ), ']', '' ) AS col,

字段名B

FROM

表名

WHERE

条件 IS NOT NULL

) AS a

JOIN mysql.help_topic AS b ON b.help_topic_id < (

char_length( a.col ) - char_length(

REPLACE ( a.col, ',', '' ))+ 1)

猜你喜欢

转载自blog.csdn.net/qq_41497074/article/details/131555260