mysql中利用sql语句来提取分割符
2019/10/10/17:37:49 阅读:1876 来源:谷歌SEO算法 标签:
SEO博客
下面一起来看一个mysql中利用sql语句来提取分割符,希望例子对各位会带来帮助.
1 K_GLF|K_GLJYJE|K_GLJYSBM|K_GLNR|K_BM|K_DXBM|K_XJLLB
2 K_GLF|K_GLJYJE|K_DXBM|K_BM|K_XJLLB
3 K_GLF|K_BM|K_XJLLB
如何用SQL取出结果,把里面的 “|”给提取出来,代码如下:
- 1||||||
- 2||||
- 3||
- mysql>select*fromtest;
- +—————————————————–+
- |name|
- +—————————————————–+
- |K_GLF|K_GLJYJE|K_GLJYSBM|K_GLNR|K_BM|K_DXBM|K_XJLLB|
- |K_GLF|K_GLJYJE|K_DXBM|K_BM|K_XJLLB|
- |K_GLF|K_BM|K_XJLLB|
- +—————————————————–+
- 3rowsinset(0.00sec)
- mysql>selectrepeat(‘|’,length(name)-length(replace(name,’|',”)))fromtest;
- +——————————————————-+
- |repeat(‘|’,length(name)-length(replace(name,’|',”)))|
- +——————————————————-+
- ||||||||
- ||||||
- ||||
- +——————————————————-+
- 3rowsinset(0.00sec)//开源代码phpfensi.com
热门评论