The Subquery In a SELECT Statement

The Subquery in a SELECT Statement

Code Sample:

1    USE world;
2    SELECT name, population 
3    FROM city 
4    WHERE CountryCode IN 
5        (SELECT code 
6        FROM country 
7        WHERE region = 'Caribbean') 
8    ORDER BY population 
9    LIMIT 5;



SELECT name, population

FROM city

WHERE CountryCode IN

(SELECT code

 FROM country

 WHERE region = 'Caribbean')

CC BY-NC-ND International 4.0

CC BY-NC-ND International 4.0: This work is released under a CC BY-NC-ND International 4.0 license, which means that you are free to do with it as you please as long as you (1) properly attribute it, (2) do not use it for commercial gain, and (3) do not create derivative works.