mysql 创建 存储函数 split_string
时间:2021-07-01 10:21:17
帮助过:13人阅读
创建存储函数
DROP FUNCTION IF EXISTS SPLIT_STR;
-- 判断是否存在,存在则删除
CREATE FUNCTION SPLIT_STR(
x VARCHAR(
255),
delim VARCHAR(
12),
pos INT
) RETURNS VARCHAR(
255)
DETERMINISTIC
BEGIN
RETURN REPLACE(
SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
LENGTH(SUBSTRING_INDEX(x, delim, pos -1))
+ 1),
delim, ‘‘);
END;
2、调用方法
SELECT split_str(‘7654,7698,7782,7788‘,‘,‘,1) as one,
split_str(‘7654,7698,7782,7788‘,‘,‘,2) as two,
split_str(‘7654,7698,7782,7788‘,‘,‘,3) as three,
split_str(‘7654,7698,7782,7788‘,‘,‘,4) as forms
mysql 创建 存储函数 split_string
标签:UNC sel rmi forms 判断 font min div create