mysql实现字符串分割(split)功能

数据库表bim_section_managementpath中存储的值为 a.b.c.d 的字符串形式,以 . 分割,实现查询具体的sql如下:

select
DISTINCT substring_index( substring_index(t1.path,'.',t2.help_topic_id + 1), '.' ,-1 )
from bim_section_management t1 join mysql.help_topic t2 on t2.help_topic_id < (length(t1.path) - length(REPLACE(t1.path,'.','')) + 1 )

如果复用只需要替换加粗部分代码即可。该方法需要明确a,b,c,d字符长度均相同一致才会分割生效,有一定局限性。

原文地址:https://www.cnblogs.com/id-tangrenhui/p/11928357.html