Posts

Showing posts from April, 2023

SQL Sub-Queries explained

Image
  Sub-Query  A sub-query is a query that is used within another query to retrieve data that will be used to manipulate the result of the main query. Here the output of inner query will be the input for outer query.It is also known as nested query or inner query. There are 3 main types of sub-query: - 1. Single-row sub-query: - A single row sub-query is a query in which inner query returns(or output) only row of data which  will be provided as an input to the outer query. To pass output of inner query output to outer query input we use '=' operator.   2. Multi-row sub-query: - A multi-row sub-query is a query where we get multiple output from inner query and those output will be passed as input to the outer query. To pass output of inner query output to outer query input we use 'IN' operator. 3. Co-related sub-query: - Co-related sub-query is a query that uses values from the outer query to filter or manipulate the result of the sub-query. It used to retrieve data tha...