給定表格Contracts
,Contract_Plans
和Contract_Plan_Tags
,我可以從內部聯接查詢中的所有三個選擇特定字段嗎?從兩個內部聯接中選擇特定字段
目前,我有
SELECT * FROM Contracts
INNER JOIN Contract_Plans
ON Contracts.ContractNum = Contract_Plans.ContractNum
INNER JOIN Contract_Plan_Tags
ON Contracts.ContractNum = Contract_Plan_Tags.ContractNum
WHERE Contract_Plan_Tags.tag_id = 44 OR Contract_Plan_Tags.tag_id = 45
此查詢返回的所有領域,但有什麼辦法可以選擇從連接表的具體領域?
我知道我可以做
SELECT ContractNum, ContractName FROM Contracts
...
...
,但只有選擇從Contracts
,而不是其他表中的字段。
SELECT Contracts.This, Contract_Plan_Tags.That, Contract_Plans.There FROM Contracts
INNER JOIN Contract_Plans
ON Contracts.ContractNum = Contract_Plans.ContractNum
INNER JOIN Contract_Plan_Tags
ON Contracts.ContractNum = Contract_Plan_Tags.ContractNum
WHERE Contract_Plan_Tags.tag_id = 44 OR Contract_Plan_Tags.tag_id = 45