Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Differentiating results of SELECT query
I am working with two tables, "rides" and "locations" both shown below.
The 'start' and 'end' fields in table "rides" relate to the
'location_key' in table "locations."
I need to design a query where I can differentiate the start address from the end address. I am looking for a way to produce the same result that these two queries produce, but in a single query. If only Union functioned a little differently...
SELECT address AS start_address, ride_key
FROM rides, locations
WHERE ride_key = '8'
AND START = location_key
SELECT address AS end_address, ride_key
FROM rides, locations
WHERE ride_key = '8'
AND END = location_key
Table: rides
+-------------+---------+-------+
| ride_key | start | end |
+-------------+---------+-------+
| 8 | 15 | 16 |
+-------------+---------+-------+
Table: locations
+-------------------+-----------------------------+Received on Wed Dec 13 2006 - 01:55:57 CST
| location_key | address |
+-------------------+-----------------------------+
| 15 | 1234 Wilsher Blvd. |
| 16 | 999 Sunset Blvd |
+-------------------+-----------------------------+