目录
环境
文档用途
详细信息
环境
系统平台:Microsoft Windows (64-bit) 2012
版本:5.6.5
文档用途
对MySQL函数substring_index(str,delim,count)进行兼容
详细信息
MySQL函数功能:按照关键字截取字符串,substring_index(被截取字段,关键字,关键字出现的次数)
HGDB函数:
create or replace function substring_index(text,text,int) returns text as $$ declare a text; b text :=""; var int; begin for var in 1..$3 loop a=split_part($1,$2,var); b=b || $2 || a; end loop; return substring(b from 2 for length(b)); end $$ language plpgsql |
例子:
MySQL:
mysql> select substring_index("fhafjkdalsfhiad,fjadsoj;f,adsf,dsfa","s",3); +--------------------------------------------------------------+ | substring_index("fhafjkdalsfhiad,fjadsoj;f,adsf,dsfa","s",3) | +--------------------------------------------------------------+ | fhafjkdalsfhiad,fjadsoj;f,ad | +--------------------------------------------------------------+ 1 row in set (0.00 sec) |
HGDB:
highgo=# select substring_index("fhafjkdalsfhiad,fjadsoj;f,adsf,dsfa","s",3); substring_index ------------------------------ fhafjkdalsfhiad,fjadsoj;f,ad (1 行记录) |
更多详细信息请登录【瀚高技术支持平台】查看https://support.highgo.com/#/index/docContent/9a21c30204850ea3