Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
How can I split a column into multiple columns so that each column contain the values for different ID?

SQL
select ID, Value from table1


ID Value
==========
1 test1
1 test2
2 test3
2 test4
2 test5
2 test6

I want the resultset split in multiple parts based on the ID column. Each ID need to have different column

ID Value ID Value
==========================
1 test1 2 test3
1 test2 2 test4
2 test5
2 test6
Posted
Updated 13-Jan-16 0:43am
v2

1 solution

Are you using MySQL only?
There some easy options, for example:
SQL
create table new select id,value from table1 where id = 1;
 
Share this answer
 
Comments
Member 12261247 14-Jan-16 0:50am    
Thanks JanPaul. Yes I am using MySQL. Looks like your query will return only 2 columns where ID =1. How to include 3rd and 4th column where ID = 2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900