Dears ;
I want to show the details of a master in a column and each items should be seperated with comma. For example: I have two tables Countries and States, CountryID is foreign key in states table so data is as follows.
CountryID Country
1 U.S.A.
2 Pakistan
StateID CountryID State
1 1 California
2 1 Illinois
3 1 Washington
4 2 Sind
5 2 Punjab
6 2 N.W.F.P
Now I want to show the data like this:
Country States
U.S.A California, Illinois, Washington
Pakistan Sind, Punjab, N.W.F.P
I have done it using cursor but I don't want to use cursor and I need a query which solve this problem.
Help will be appriciated.
Muhammad Essa Mughal
Software Engineer
essamughal@yahoo.com
I want to show the details of a master in a column and each items should be seperated with comma. For example: I have two tables Countries and States, CountryID is foreign key in states table so data is as follows.
CountryID Country
1 U.S.A.
2 Pakistan
StateID CountryID State
1 1 California
2 1 Illinois
3 1 Washington
4 2 Sind
5 2 Punjab
6 2 N.W.F.P
Now I want to show the data like this:
Country States
U.S.A California, Illinois, Washington
Pakistan Sind, Punjab, N.W.F.P
I have done it using cursor but I don't want to use cursor and I need a query which solve this problem.
Help will be appriciated.
Muhammad Essa Mughal
Software Engineer
essamughal@yahoo.com