Как мне объединить два моих запроса?
Я пытаюсь объединить эти запросы, но безуспешно. Мне нужно иметь возможность поддерживать все столбцы в результате. Как я могу это сделать?
Это мои запросы:
SELECT c.CustomerID, EmailAddress, LastName, FirstName, Line1 AS BillLine1, Line2
AS BillLine2, City AS BillCity, State AS BillState, ZipCode AS BillZip FROM
Customers c JOIN Addresses ON c.BillingAddressID = Addresses.AddressID
SELECT Line1 AS ShipLine1, Line2 AS ShipLine2, City AS ShipCity, State AS ShipState,
ZipCode AS ShipZip FROM Customers b JOIN Addresses ON b.ShippingAddressID =
Addresses.AddressID;
1 ответ
Может как то так? S
ELECT
c.CustomerID,
EmailAddress,
LastName,
FirstName,
a1.Line1 AS BillLine1,
a1.Line2 AS BillLine2,
a1.City AS BillCity,
a1.State AS BillState,
a1.ZipCode AS BillZip,
a2.Line1 AS ShipLine1,
a2.Line2 AS ShipLine2,
a2.City AS ShipCity,
a2.State AS ShipState,
a2.ZipCode AS ShipZip
FROM
Customers c
JOIN Addresses a1 ON c.BillingAddressID = a1.AddressID
JOIN Addresses a2 ON c.ShippingAddressID = a2.AddressID