在列MYSQL中分割逗号分隔的值 [英] Split Comma separated Values in Column MYSQL
本文介绍了在列MYSQL中分割逗号分隔的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的结果集
id cpumanufacturer cpuseries
200014 Intel Core i7,Core i7 Extreme Edition
200015 Intel Core i7 Extreme Edition,Core i7
200259 Intel Core i7 Extreme Edition,Core i7
我想将CPU系列拆分为多行 例如对于第一行"输出应该是
I want to split cpu series to spanned across multiple rows like for First Row output should be
200014 | Intel | Core i7
200014 | Intel | Core i7 Extreme Edition
推荐答案
有一篇博客文章描述了一个存储过程,该存储过程将从此修改表:
There is a blog post that describes a stored procedure that will modify your table from this:
id cpumanufacturer cpuseries
200014 Intel Core i7,Core i7 Extreme Edition
200015 Intel Core i7 Extreme Edition,Core i7
200259 Intel Core i7 Extreme Edition,Core i7
对此:
id cpumanufacturer cpuseries
200014 Intel Core i7
200014 Intel Core i7 Extreme Edition
200015 Intel Core i7 Extreme Edition
200015 Intel Core i7
200259 Intel Core i7 Extreme Edition
200259 Intel Core i7
博客文章: http://www.marcogoncalves.com/2011 /03/mysql-split-column-string-into-rows/
请记住,这将修改表,而不是查询结果.
Keep in mind that this will modify the table, not your query results.
您可能还会发现以下答案很有用: https://stackoverflow.com/a/5344071/1005039
You may also find the following answer useful: https://stackoverflow.com/a/5344071/1005039
这篇关于在列MYSQL中分割逗号分隔的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文