1
一个观点我有2个表:创建SQL Server中
Contracts
(使用ContactID,ContractNo,estimatedCost,CurrencyEstimatedCostID,ContractCost,CurrencyContractCostID)CurrencyTypes
(CurrencyID,CurrencyTypeName)。
我想CurrencyTypeName
查看合同表代替外键CurrencyEstimatedCostID
和CurrencyContractCostID
在示意图(在SQL Server视图)。
我使用这个查询,但它只返回CurrencyTypeName
(我想每个CurrencyEstimatedCostID
和CurrencyContractCostID
)的一列。
SELECT
Contracts.contractID, Contracts.ContractNo, CurrencyTypes.CurrencyType
FROM
Contracts
INNER JOIN
CurrencyTypes ON Contracts.CurrencyEstimatedCostID = CurrencyTypes.CurrencyType
AND Contracts.CurrencyContractCostID = CurrencyTypes.CurrencyType
如何更改查询?
不该”你加入CurrencyId而不是CurrencyType? –
@TienDinh:是的,最有可能的 - 最初的问题有这个连接条件,但这真的没有任何意义,你是对的 –
@marc_s谢谢。 – Question