-1

I have 3 tables; A,B,C

A is in relation with B and B is in relation with C

I want to use select query on A and take a column of C in the query

Using inner join, I can only reach B but I want to reach C which has no direct relation with A

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 3
    Could that be any more abstract? If you use real table names and show example data and expected output the question would be clearer. – juergen d Feb 09 '20 at 07:29
  • [FKs ("relationships") are not needed to query.](https://stackoverflow.com/a/23842061/3404097) Tables represent relation(ship)s/associations. What a row in a table says in terms of its columns is necessary & sufficient to query. – philipxy Feb 09 '20 at 09:29

1 Answers1

4

In this case you need to use 2 inner joins to get data from tablec like following.

select a.*,c.coltoselect
from tablea a
inner join tableb b on a.abcommoncolumn=b.abcommoncolumn
inner join tablec c on b.bccommoncolumn=c.bccommoncolumn
PSK
  • 17,547
  • 5
  • 32
  • 43