我认为查询的屏幕截图几乎是不言自明的。
我需要的只是从CustomerAddresses表中获取2个地址,而不是像本示例中那样仅获取1个地址。 ShippingAddress为 1,BillingAddress为 。
听起来这很容易解决这个问题,但显然我错过了一些东西。提前谢谢..
答案 0 :(得分:2)
您需要加入包含地址两次的表。一次为ShippingAddressID
,一次为BillingAddressID
:
SELECT
...
ShippingAddress.Address as 'ShippingAddress',
BillingAddress.Address as 'BillingAddress',
...
FROM
...
INNER JOIN CustomerAddresses as ShippingAddress
ON Orders.ShippingAddressID = ShippingAddress.CustomerAddressID
INNER JOIN CustomerAddresses as BillingAddress
ON Orders.BillingAddressID = BillingAddress.CustomerAddressID