Select 来自具有联接的多个表
Select result from multi tables with joins
我有这个问题。我想 select
surgery Type
surgery Details
Modality ID
我至少走在正确的道路上吗?
LINK
table是一切的中间
Addmission
1toM on LINK
Surgery
Mto1 on LINK
Modality
Mto1 on LINK
我的问题是将 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
本例尝试使用:
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
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
我有这个问题。我想 select
surgery Type
surgery Details
Modality ID
我至少走在正确的道路上吗?
LINK
table是一切的中间
Addmission
1toM onLINK
Surgery
Mto1 onLINK
Modality
Mto1 onLINK
我的问题是将 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
本例尝试使用:
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
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