On Fri, May 23, 2008 at 11:27 AM,  <[EMAIL PROTECTED]> wrote:
> I have a table that has two has two secondary keys referencing the same 
> primary key of another.
>
>     Table-name =Circuits
>     circuitID
>     CircuitID
>     A_loc
>     Z_loc
>
>     Table-name = Location
>     locationID
>     location
>
> circuits.A_loc    references    locatioin.locationID
> circuits.Z_loc    references    locatioin.locationID
>
>
> How do i achieve the following output.
>
>    circuitID   Location A     LocationZ
>      98129       BOSTON        ATLANTA
>
>
> Do I actually have to create two location tables one for the A location and 
> one for the Z location.

SELECT circuitID,
              l1.location AS 'Location_A',
              l2.location AS 'Location_Z'
FROM Circuits
        INNER JOIN  Location AS l1 WHERE circuits.A_loc  =l1.locationID
        INNER JOIN  Location AS l2 WHERE circuits.Z_loc  =l2.locationID


-- 
Rob Wultsch
[EMAIL PROTECTED]
wultsch (aim)

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to