mysql表字段分割全部
单个分割(取第一个)
·
单个分割(取第一个)
SELECT SUBSTRING_INDEX(name, ',',1) AS result FROM ppm_order;
全部分割
SELECT
SUBSTRING_INDEX(SUBSTRING_INDEX(name, ',', n.n), ',', -1) AS name
FROM
表
JOIN
(SELECT 1 AS n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4) n
WHERE n.n <= LENGTH(name) - LENGTH(REPLACE(name, ',', '')) + 1;
更多推荐
已为社区贡献1条内容
所有评论(0)