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
 General SQL Server Forums
 New to SQL Server Programming
 joining 3 tables

Author  Topic 

mjohnjoseph
Starting Member

2 Posts

Posted - 2008-06-27 : 02:12:36
Hi,
i have three tables.
A which has columns AName,AId(pk).
B which has columns BName,Bid(pk).
C which has a composite primary key Aid(pk), Bid(pk).

i want a query which retrieves AName and BName. what i wrote is giving me error:

select AName, BName from A,B inner join on C (a.Aid = c.Aid) and (b.Bid = c.B.id)

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-06-27 : 02:15:18
[code]SELECT AName, BName
FROM C
INNER JOIN A ON C.AID = A.AID
INNER JOIN B ON C.BID = B.BID[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-27 : 02:18:24
Make sure you use ANSI join syntax throughout as the older syntax wont be supported from SQL 2005 compatiility level 90 onwards.
Go to Top of Page

mjohnjoseph
Starting Member

2 Posts

Posted - 2008-06-27 : 07:13:08
Thanks tht helped :)
Go to Top of Page
   

- Advertisement -