Join 2 tables on 2 different conditions and accessin results
Posted: Fri Jun 01, 2007 11:11 am
I have two tables.
One is called 'map' with fields 'id', 'x', and 'y'.
The other table is called 'users' with fields 'user_id, 'location_id' and 'destination_id'.
For starters I(we) will assume each table has only one row.
For each of location_id and destination_id, I wish to get the map coordinates.
I thought something like this might work, but I dont know how to access the results / how to distinguish between the location coordinates and destination coordinates.
Any ideas how I should do this? - I guess I am taking the wrong approach... 
Thanks
Shears
One is called 'map' with fields 'id', 'x', and 'y'.
The other table is called 'users' with fields 'user_id, 'location_id' and 'destination_id'.
For starters I(we) will assume each table has only one row.
For each of location_id and destination_id, I wish to get the map coordinates.
I thought something like this might work, but I dont know how to access the results / how to distinguish between the location coordinates and destination coordinates.
Code: Select all
SELECT * FROM users
INNER JOIN map ON users.location_id = map.id
INNER JOIN map ON users.destination_id = map.id
Thanks
Shears