我正在介绍数据库类,但我的查询遇到了问题。我正在尝试返回将为 PurchaseOrderHeader 生成的信息。我不能让它返回任何东西。
Use [Sandwiches Inc]
GO
DECLARE
@VendorID INT,
@TodaysDate DATETIME,
SELECT @VendorID = 3,
@TodaysDate = GETDATE();
SELECT
@VendorID AS Vendor,
@TodaysDate AS TDate,
V.Name,
V.Phone,
A2.Address1,
A2.Address2,
A2.AdressState,
A2.City,
A2.Zip,
A1.Address1,
A1.Address2,
A1.AdressState,
A1.City,
A1.Zip
FROM Vendor AS V
INNER JOIN VendorAddress AS VA1 on V.VendorId = VA1.VendorId
--INNER JOIN VendorAddress AS VA2 on V.VendorId = VA2.VendorId
INNER JOIN VdrAddress as A1 on VA1.VdrAddressId = A1.VdrAddressId
INNER JOIN VdrAddress AS A2 on VA1.VdrAddressId = A2.VdrAddressId
WHERE A1.Name = 'Billing' And A2.Name = 'Shipping' And V.VendorId = 3
GO
就像现在一样,它执行但不返回任何列。如果我只做 A1 或 A2 并注释掉其中一个,它就可以了。正是当我尝试同时做这两件事时,它才会失败。
任何帮助,将不胜感激。如果您需要更多信息,我可以详细说明。