Nested Queries

By now, you know that a database is a collection of multiple related tables. Now, while generating insights from data, you may need to refer to these multiple tables in a query. There are two ways to deal with such types of queries:

  • Joins
  • Nested queries/Subqueries

In the upcoming videos, you will learn about nested queries/subqueries. You will learn about joins in the next session.

Subqueries are a generic form of writing queries wherein you do not need to specify some value explicitly (either minimum or maximum, or some other value). If any update is made to a table, then the subquery would still return the required output as it is independent of any particular value in the table. Now, let’s move on to the next and learn more about nested queries.

To summarise, in this segment, you learnt about nested queries, which are typically used when you have to select columns from one table based on the filter conditions from another table. In such cases, you write a subquery inside the ‘where’ clause, instead of a specific value.

Write a query to retrieve the names of all customers who have a credit limit greater than what La Rochelle Gifts has.

Report an error