内联三桌 [英] Inner Join Three Tables

查看:62
本文介绍了内联三桌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Oracle APEX中工作.我想通过INNER JOIN从三个表中生成报告.这些表就像Fallows.

I am working in Oracle APEX.i want to make a report from three tables through INNER JOIN .The Tables are as Fallows.

患者(Par_Id(Pk),Pat_Name,Pat_Gender)

PATIENT (Par_Id(Pk),Pat_Name,Pat_Gender)

历史记录(His_Id(Pk),Pat_id(Fk),Treated_By)

HISTORY (His_Id(Pk),Pat_id(Fk),Treated_By)

治疗( Treat_Id, His_id(Fk),Pat_id(Fk) ,Treat_Type ,费用)

Treatment ( Treat_Id, His_id(Fk),Pat_id(Fk) ,Treat_Type ,Charges)

我想显示以上三个表中提到的报告"中的所有列.

I want to display all the columns in Report mentioned in the above three Tables.

谢谢.

推荐答案

您应始终指定要返回的列,尤其是当表包含相同的列名时

You should always specify the columns to return, especially as the tables contain identical column names

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

这篇关于内联三桌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆