mysql查询 逗号分割字符串内容

-- 逗号分割 表t1, h5_service_score字段的字符串内容

SELECT

id,

h5_service_score,

SUBSTRING_INDEX( SUBSTRING_INDEX( h5_service_score, ',', n ), ',', - 1 ) AS split

FROM

`t1`,

( SELECT @rownum := @rownum + 1 AS n FROM ( SELECT @rownum := 0 ) r, `t1` ) x

WHERE

1 = 1

AND n <= ( LENGTH( h5_service_score ) - LENGTH( REPLACE ( h5_service_score, ',', '' ) ) + 1 )

ORDER BY

id;

posted @ 2024-08-12 16:38  乌云de博客  阅读(88)  评论(0编辑  收藏  举报