当前位置:Gxlcms > 数据库问题 > Mysql 字符串拆分 OR 一行转多行

Mysql 字符串拆分 OR 一行转多行

时间:2021-07-01 10:21:17 帮助过:24人阅读

substring_index(str,delim,count)

  str:要处理的字符串

      delim:分隔符

      count:计数

B.length():字符长度函数
C.replace():替换函数

不说了,直接看代码:

SELECT
    substring_index(substring_index(    a.chain,_,b.help_topic_id + 1    ),    _ ,- 1    ) AS ID
FROM
    (select 1_11_1223_1242 as chain) a  
JOIN mysql.help_topic b ON b.help_topic_id <
(length(a.chain) - length( replace(a.chain, _, ‘‘)  ) + 1)

结果??:

技术图片

 首先如果有疑问,可以在数据库进行测试,一步一步进行推断执行,你就会明白了,实践是最好的学习成长捷径。

 

Mysql 字符串拆分 OR 一行转多行

标签:inf   mamicode   image   ext   成长   代码   div   实践   col   

人气教程排行