Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do I need Cursors or there is a simpler method 1

Status
Not open for further replies.

urielk

Programmer
Jun 13, 2001
15
CA
I have two tables, mapped with a 3rd table in a one to many relationship

TableA:
AId
AName

TableB:
BId
BName

TableB2A (just a map):
CId --just to have its own PKId
AId
BId

My Query returns all the rows in the relationship using an INNER JOIN:

Code:
SELECT TableA.*, TableB2A.BId
FROM TableA INNER JOIN TableB2A ON TableA.AId = TableB2A.AId
WHERE TableB2A.BId = @findMe

... until now its easy

What I need in my query is to return all the rows with
AId, AName, BName

But I only know how to get
AId, AName, BId

 
No cursors necessary. Just add the third table into the fray.

SELECT A.*, B.BID, B.Bname
FROM TableA A
INNER JOIN TableB2A BA ON A.AID = BA.AID
INNER JOIN TableB B ON BA.BID = B.BID
WHERE BA.BID = @findMe

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top