Reputation: 5628
For my case lets assume table A has ID's 1-10 B has ID's 10-100 and c has ID's 100-1000
Now I want the following functionality: I want all names from table C that has B_ID which is has a foreign key A_ID=3
So basically lets say some names in table C would have B_ID 20,30,40,50,60 and in table B B-ID 20 and 30 have A-ID 3
So I want data from table C that has only B_ID's 20 and 30
I hope I was clear enough, I would have mentioned the query that I wrote but I dont want the reader to get confused any more.
Thanks in advance............
Upvotes: 0
Views: 30
Reputation:
I'm not sure if I'm missing something but if all you want is data from table c based on information available in that table you don't need to join to other table unless you want to verify B_ID
is present in table b
Select * from TableC where B_ID in (20,30)
Edit:
here is entire join that will return all rows from table C
where `B
SELECT C.*
FROM A
JOIN B
ON A.A_ID = B.A_ID
AND B.B_ID IN (20,30)
JOIN C
ON B.B_ID = C.B_ID
WHERE A.A_ID = 3
Upvotes: 0
Reputation: 6958
Can you try this:
SELECT C.names
FROM C
INNER JOIN B ON C.B_ID = B.B_ID
INNER JOIN A ON B.A_ID = A.A_ID
WHERE A.A_ID = 3
Upvotes: 2