我有这个查询。我想选择
手术类型
手术细节
模态ID
我是否在正确的道路上至少?
LINK
表是所有内容的中间
Addmission
上的{p>LINK
1toMSurgery
上的LINK
Mto1Modality
上的LINK
Mto1
我的问题只是在结果中添加Modality.ID
跳过模态,查询工作100%
已更新(删除了多个别名)
SELECT surg.srg_Details, surg.Type, modd.ID
FROM Surgery surg
JOIN LINK lnk on lnk.lnk_ID = surg.srg_lnkID
JOIN Modality modd ON modd.mod_lnkID = lnk.lnk_ID
JOIN Admission adm ON adm.adm_ID = lnk.lnk_admID
WHERE adm.adm_ID = 192100042
答案 0 :(得分:1)
在这种情况下尝试使用:
SELECT surg.srg_Details, surg.Type, mod.ID
FROM Surgery surg, Modality mod
JOIN LINK lnk on lnk.lnk_ID = surg.srg_lnkID
JOIN Admission adm ON adm.adm_ID = lnk.lnk_admID
WHERE adm.adm_ID = 192100042 AND surg.srg_lnkID = mod.mod_lnkID
答案 1 :(得分:0)
Try to use left Join though no match null value will be present
SELECT surg.srg_Details, surg.Type, mod.ID
FROM Surgery surg, Modality mod
left JOIN LINK lnk on lnk.lnk_ID = surg.srg_lnkID
left JOIN Modality mod ON mod.mod_lnkID = lnk.lnk_ID
left JOIN Admission adm ON adm.adm_ID = lnk.lnk_admID
WHERE adm.adm_ID = 192100042