Forum Moderators: coopster
tableA contains a column 'aLocation' which I need to look up in 'bLocation' in tableB.
tableB also has a colum 'bDistrict' that allows me to look up other data in tableC
How can I do a SELECT on tableA joining to tableB and in turn, looking up the correct row in tableC?
There is a possibility of null fields in the 'aLocation' column of tableA
Thanks in anticipation.
Your WHERE clause determines which rows are returned as well.
SELECT
tableA.aLocation,
tableB.bDistrict,
tableC.*
FROM tableA
LEFT JOIN tableB ON (tableA.aLocation = tableB.bLocation)
LEFT JOIN tableC ON (tableB.bDistrict = tableC.cDistrict)
WHERE tableA.aLocation IS NOT NULL
;