使用sql查询在oracle 11g中连接多个表

时间:2015-08-18 21:10:49

标签: oracle

我想要treat_info表的所有列以及相应的处理表和设备表费用。什么是sql查询? 3表图像链接如下 enter image description here

1 个答案:

答案 0 :(得分:0)

我决定使用“LEFT JOIN”来确定这些字段是否为TREATMENT,而EQUIPMENT是外键。

因此,您有FEE值(如果存在)。

select
T1.*
,T2.FEE as TREATMENT_FEE
,T3.FEE as EQUIP_FEE
from TREAT_INFO as T1
left join TREATMENT as T2 on T2.TREATMENT = T1.TREATMENT
left join EQUIPMENT as T3 on T3.EQUIPMENT = T1.EQUIPMENT