Non Correllated SubQueries - II - why is "code" being selected in the inner query?


#1

I am understanding "origin" in the outer query is matching the faa_region in the inner query and it is producing the correct results.

SELECT * 
FROM flights 
WHERE origin in (
    SELECT code 
    FROM airports 
    WHERE faa_region = 'ASO');

What I'm not understanding is why "code" is in the select clause of the inner query. What purpose does it serve? It doesn't appear to match anything in the flights table.

Thank you.


#2

@bcoble23,
With your
SELECT code FROM airports WHERE faa_region = 'ASO'
you create a list
SOUTHERN REGION.
ALABAMA · FLORIDA · GEORGIA · KENTUCKY · MISSISSIPPI · NORTH-CAROLINA · SOUTH-CAROLINA · TENNESSEE.

represented by code

You then check if your flight starts from the origin Airport.

Have a look at the table-structures using
+++ show all table defintions
select * from sqlite_master;


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.