|
Posted by chrisek on 06/23/06 09:42
Hello,
I have 2 tables:
- Customers with columns:
customerID(prim_key),
customerName(with customer's names)
- Deliveries with columns:
deliveryID(primKey),
sender(ref_key to CustomerID from Customers),
receiver(also ref_key to CustomerID from Customers);
I need to select all data about deliveries, but instead of having
sender's ID and receiver's ID, I need to have their Names.
I tried to do:
SELECT
deliveries.deliveryID,
Customers.customerName AS sender,
Customers.customerName AS receiver
FROM
customers, deliveries
WHERE
Customers.customerID=Deliveries.sender AND
Customers.customerID=Deliveries.receiver;
But this only works if sender=receiver, which is obvious ;)
I'd like to know if there is any other way for obtaining those data
within one query
Thank you very much for your help
Chris
[Back to original message]
|