โ† All SQL Flashcard Decks

Writing Subqueries Flashcards

7 cards from real SQL practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Writing Subqueries flashcards as text
  1. Which keyword tests whether a subquery returns any rows at all?

    Answer: EXISTS

    EXISTS returns TRUE if the subquery produces one or more rows.

  2. A subquery that references a column from the outer query is called what?

    Answer: Correlated subquery

    A correlated subquery depends on a column supplied by the outer query and runs per outer row.

  3. What does a scalar subquery return?

    Answer: A single value

    A scalar subquery returns exactly one row and one column, i.e., a single value.

  4. Which operator lets a value match ANY result from a subquery returning multiple rows?

    Answer: IN

    IN checks whether a value matches any value in the subquery's result set.

  5. Where can a subquery used as a derived table appear?

    Answer: In the FROM clause

    A derived table is a subquery placed in the FROM clause and must be given an alias.

  6. What is required when a subquery is compared with = (equals)?

    Answer: It must return a single value

    Using = with a subquery requires the subquery to return exactly one value, or an error occurs.

  7. Which clause CANNOT typically contain a subquery in standard SQL?

    Answer: The keyword list of an INDEX definition

    Subqueries appear in SELECT, FROM, WHERE, and HAVING, but not within an index column definition.