Subqueries are used to retrieve data from a table in SQL. They are also known as cross-joins.
There are many types of subqueries that can be used in SQL.
- Example 1: With a subquery, we can retrieve data from the same table, but with different conditions.
- Example 2: We can use a subquery to return all the rows that meet a certain condition.
- Example 3: A subquery is useful when we need to select only one column from more than one table, but with different conditions.