Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

Junção interna de três tabelas


Você deve sempre especificar as colunas a serem retornadas, especialmente porque as tabelas contêm nomes de colunas idênticos
SELECT p.Par_Id, p.Pat_Name, p.Pat_Gender,
    h.His_Id, h.Treated_By,
    t.Treat_Id, t.Treat_Type, t.Charges
FROM Patient p 
INNER JOIN History h 
    ON p.PAR_ID = h.PAT_ID
INNER JOIN Treatment t
    ON h.HIS_ID = t.HIS_ID AND p.PAR_ID = h.PAT_ID