Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mrsaif
Starting Member
43 Posts |
Posted - 2008-04-26 : 04:25:54
|
| i have 2 columns likeCol1====col2username=======saif====mr@hotmai.comemail=======saif@hotmail.comname======saifullahI want to get these records from sql likeusername email namesaif saif@hotmail.com saifullah________________________________-how can I achive thisMuhammad Saifullah |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-26 : 04:47:07
|
| SELECT IDColumn, MAX(CASE WHEN Col1='username' THEN Col2 END) AS usename, MAX(CASE WHEN Col1='email' THEN Col2 END) AS email, MAX(CASE WHEN Col1='name' THEN Col2 END) AS nameFROM YourTableGROUP BY IDColumn |
 |
|
|
mrsaif
Starting Member
43 Posts |
Posted - 2008-04-26 : 05:04:11
|
| in this case only one record is select...What if i have multipule records for username email and name??????Muhammad Saifullah |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-26 : 05:16:55
|
| Nope. You will get one record for each id in your table. Post you table structure and some sample data if you want the complete solution. |
 |
|
|
|
|
|