我有3个表都与外键链相关
Table1:
ID
name
--------
Table2:
ID
name
T1_ID
------
Table3:
ID
name
T2_ID
让我们说我需要选择所有表名,我会写一个查询:
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
但如何选择我现在不知道相关列,我只能编写1个SQL查询。我需要写什么而不是 ???
select Table1.name, Table2.name, Table3.name
from Table1
join Table2 on ???
join Table3 on ???