简体   繁体   中英

Joining multiple table in oracle 11g using sql query

i want all the column of treat_info table and corresponding fee of treatment table and equipment table.what is the sql query ? The 3 tables image link is below https://drive.google.com/file/d/0B3BFGC_k79UObHRjMGZpVXZwa3M/view?usp=sharing

I decided to use "LEFT JOIN" for not be sure if the fields are TREATMENT and EQUIPMENT are foreign keys.

So, you have the FEE value, if they exist.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM