就爱编程论坛

标题: MySQL中利用存储过程分割字符串的方法 [打印本页]

作者: admin    时间: 2012-5-25 17:20:26     标题: MySQL中利用存储过程分割字符串的方法

现有一段字符串,如apple,banana,orange,pears,grape,要把它按照逗号(,)分割成:
apple
banana
orange
pears
grape
然后使用where in()方法可以查询。
1、具体函数:2、测试是否能成功分割 运行结果如下,说明分割成功:
mysql> call splitString("apple,banana,orange,pears,grape",",");
select * from tmp_split;
Query OK, 1 row affected

+--------+
| status |
+--------+
| apple  |
| banana |
| orange |
| pears  |
| grape  |
+--------+
5 rows in set

mysql>
3、应用where in()查询




欢迎光临 就爱编程论坛 (http://bbs.waibc.com/) Powered by Discuz! X2