2012-04-24 245 views
1

這裏是我的結果集拆分逗號列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系列橫跨多行 像第一行輸出跨度應

200014 | Intel | Core i7 
200014 | Intel | Core i7 Extreme Edition 

回答

2

有一個描述一個存儲過程的博客帖子,它將修改你的表格:

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/

請記住,這將修改表,而不是查詢結果。

您可能還會對以下答案有幫助: https://stackoverflow.com/a/5344071/1005039