Non-Correlated Subqueries II

Hi!

Can someone explain why ‘origin’ and ‘code’ are used in Subquerriey II? I understand subquerries when it involves a < or = sign after the WHERE, but I am not sure what this code exactly does…

Thanks in advance!

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

Hi!

As I understand it, the subquery that is inside the brackets creates a list of codes from the table airports, where the code is in the faa_region ASO. The outer query then returns all flights if their origin is among the list of the codes that the subquery created. Does that make sense?

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