8.11. SQL Select Subquery

8.11.1. Rationale

  • IN (SELECT ...) - subquery

8.11.2. Subqueries

SELECT *
FROM astronauts
WHERE agency IN (
    SELECT name FROM agencies);
SELECT *
FROM astronauts
WHERE career IN (
    SELECT name FROM job_names);
SELECT *
FROM logs
WHERE level in (

    SELECT level
    FROM logs
    GROUP BY level
    HAVING COUNT(*) > 5

);