Non-Correlated Subqueries II 3/7, Can anyone explain in basic language why "code" is used after select in the inner query?

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/sql-table-transformation/lessons/subqueries/exercises/non-correlated-i?action=lesson_resume

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
It behaves as is, but I’m just trying to understand what is happening, cause the current text doesn’t really explain it well enough.
<In this course, it often helps to include a screenshot of your whole web browser – that lets everyone see what you see. If you wish to include a screenshot, add it below this line.>

<If you wish to copy/paste in your code, you can use this next section. This will allow others to copy/paste your code for testing – something that they won’t be able to do with just a screenshot.>

```

select * from flights where origin in (select code from airports where elevation < 2000);

<do not remove the three backticks above>

That exercise is having you use a subquery (so you’re pulling information from another table, not just the “flights” table). Try running this query:

SELECT*FROM airports;

You’ll see that “code” is a column in the “airports” table.

Hi,

I’m doing the SQL-Courses since today and slowly I’m losing the grip, so I need to start asking questions:

I don’t understand how this works in terms of, I understand how subquery works, cause there is clear question: SELECT (Display) FROM airports WHERE elevation < 2000

BUT

Where is the connection between the codes and the flights? How does the “main” query know which fly it needs to “display” or to select?

I hope you understand my question.

Thanks in Advance!

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