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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Querying the results

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-04-17 : 10:38:53
kittu writes "Hello,
I am in a situation where I just want to query the results of the database that is related to three tables.
I am giving the situation as follows:

Table1:
rid name details
1 test testdetails
2 two twodetails
3 three threedetails


Table2:
cid rid
1 1
2 1
3 1
2 2
3 2
1 3

Table3:
cid cname
1 cone
2 ctwo
3 cthree


Now my requirement is I should get the result as follows:

Results:
rid name details cname
1 test testdetails cone,ctwo,cthree
2 two twodetails ctwo,cthree
3 three threedetails cone


****Can you please tell me how to do that.
The query which I am running is getting as follows

select a.rid,a.name,a.details,b.cname from table1 a,table3 b,
table2 c where a.rid=c.rid and c.cid=b.cid

Results:
rid name details cname
1 test testdetails cone
1 test testdetails ctwo
1 test testdetails cthree
2 two twodetails ctwo
2 two twodetails cthree
3 three threedetails cone"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-17 : 10:44:10
Refer this
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -