码迷,mamicode.com
首页 > 数据库 > 详细

mysql字符串分割操作

时间:2018-05-10 15:46:30      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:path   结果   HERE   sub   substring   alt   测试   image   index   

SELECT 1,2,3,4,5,6,7,8 FROM dual;

-- 列转行分割
SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(a.path,,,b.help_topic_id + 1),,,-1)  
FROM  
(SELECT GROUP_CONCAT(REPLACE(path,/,,)) AS path FROM department b WHERE department_type = 1) a
JOIN 
mysql.help_topic b 
ON b.help_topic_id < (LENGTH(a.path) - LENGTH(REPLACE(a.path,,,‘‘)) + 1);



-- 测试
SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(a.path,,,b.help_topic_id + 1),,,-1) as path
FROM  
(SELECT 1,2,3,4,5,6,7,8 as path FROM dual) a
JOIN 
mysql.help_topic b 
ON b.help_topic_id < (LENGTH(a.path) - LENGTH(REPLACE(a.path,,,‘‘)) + 1);

测试结果:

技术分享图片

 

mysql字符串分割操作

标签:path   结果   HERE   sub   substring   alt   测试   image   index   

原文地址:https://www.cnblogs.com/wangwiz/p/9019472.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!