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 |
|
Y2K
2 Posts |
Posted - 2009-02-09 : 06:27:28
|
| hi,i need help on putting the records that are returned for 1 common value. For example: A and B are the two tablesTable A holds the continents name (Asia,America etc)and B has all the countries stored in it.I want all the countries coming under Asia to be in one row like,Asia: India, China,Sri lanka etcRight now, i am getting the result as:Asia IndiaAsia ChinaSo, I want the all the entries to be put into one row with comma seperated that come under a single ontinent.Thanks. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2009-02-09 : 07:13:41
|
| select distinct continent,stuff((select distinct ',' + country from tableB where continentid = a.continentid for xml path('') ),1,1,'') as 'countries'from tableA aJai Krishna |
 |
|
|
|
|
|