I have 3 tables all related to chain by foreign keys
Table1:
ID
name
--------
Table2:
ID
name
T1_ID
------
Table3:
ID
name
T2_ID
Let's say i need to select All tables names i would write a query:
select Table1.name, Table2.name, Table3.name
from Table1
join Table2 on Table1.ID = Table2.T1_ID
join Table3 on Table2.ID = Table3.T2_ID
but how to select if i don't know the related columns now and i can only write 1 sql query. What i need to write instead of ???
select Table1.name, Table2.name, Table3.name
from Table1
join Table2 on ???
join Table3 on ???