在存储过程中将分隔字符串拆分为变量 [英] Split a delimited string into variables in stored procedure

查看:66
本文介绍了在存储过程中将分隔字符串拆分为变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
Mysql 可以拆分列吗?

我将把一个包含过滤参数的逗号分隔字符串从我的 java 代码传递到我的 mysql 存储过程.这将由过程的 IN 参数之一获取.

I am going to pass a comma separated string consisting of filter parameters from my java code to my mysql stored procedure. This will be fetched by one of the IN parameters of the procedure.

我想将此逗号分隔的字符串拆分为单独的变量,并在不同的查询中使用它们.

I want to split this comma separated string into separate variables and use them in different queries.

在谷歌搜索中我发现了 这个 MySQL 子字符串功能

On googling I found this MySQL substring function

但是有一个问题:

mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2);
    -> 'www.mysql'

但我想要 www,mysql,com 没有规定将子字符串从第一个分隔符获取到下一个分隔符一个等等...

But I want www,mysql,com for which there is no provision to get the sub-string from 1st delimeter to the next one and so on...

推荐答案

MySQL 以及其他 RDBMS 不提供此类功能.

MySQL, as well other RDBMS, do not provide this kind of functionalities.

您正在寻找的是为此,一个功能齐全的分离器功能.

What you are looking for is for this, a fully functional splitter function.

在 SO 上已经多次询问您想要什么.

What you want has been asked several times right here on SO.

这里此处这里 你有同样的问题.

Here, here and here you have same question.

这篇关于在存储过程中将分隔字符串拆分为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆