玖叶教程网

前端编程开发入门

MySQL拆分字符串为多行

------------

select a2.id,substring_index(substring_index(a2.col2,',',a1.help_topic_id+1),',',-1) as split_rn

from mysql.help_topic a1,tab_name2 a2

where a1.help_topic_id < (length(a2.col2)- length(replace(a2.col2,',','')) +1)

----------------------

1、函数SUBSTRING_INDEX(str, delim, count)

(1)参数str:需要拆分的字符串

(2)参数delim:分隔符,通过某字符进行拆分,用英文字符

(3)参数count:当 count 为正数,取第 n 个分隔符之前的所有字符;

当 count 为负数,取倒数第 n 个分隔符之后的所有字符。

-------------------------------------------

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言