Search⌘ K

Use Cases for Subqueries

Let's look at situations where we might want to use subqueries.

The use of subqueries is not limited to insertion. Subqueries can be used in a variety of scenarios.

The Tournament database

To demonstrate different use cases of subqueries, we’ll use the Tournament database, which consists of these tables:

  • ActionPoints stores points earned by a player for some in-game action:

    • Id: Uniquely identifies each action performed within a game.
    • PlayerId: References the Id column of the Players table.
    • Points: represented the number of points earned.
  • Players stores information about players participating in the game:

    • Id: Uniquely identifies each
...