1

我有这个查询。我想选择

手术类型
手术详情
模态 ID

我至少在正确的道路上吗?

LINK桌子是一切的中间

Addmission1toM on LINK
Surgery Mto1 on LINK
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
4

2 回答 2

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
于 2015-04-01T12:40:49.700 回答
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
于 2015-04-01T12:48:35.563 回答