I have an orders table that contains a billingAddressID and a
shippingAddressID, which may or may not be identical.
I need to retrieve each order as a single row containing both
addresses. If Grandma Jones buys a widget for her grandson Junior, the
row would look something like:
orderID ... First Name (billing) ... First Name (shipping) ... [etc]
999999 ... Grandma ... Junior ... [etc]
The SQL needs to in effect join a single order (as defined by orderID)
to the address table twice, first on
orders.billingAddressID=addresses.addressID and then on
orders.shippingAddressID=addresses.addressID, with the column names
aliased according to which of the two joins they reference
("addresses.firstName AS First Name (shipping)...addresses.firstName
AS First Name (billing)"). I have no clue as to how to do this in SQL.