What is subquery and its types?
Matthew Cannon
Updated on January 17, 2026
A subquery is best defined as a query within a query. Subqueries enable you to write queries that select data rows for criteria that are actually developed while the query is executing at run time. More formally, it is the use of a SELECT statement inside one of the clauses of another SELECT statement.
data rows
Tuple − A single row of a table, which contains a single record for that relation is called a tuple. Relation instance − A finite set of tuples in the relational database system represents relation instance. Relation instances do not have duplicate tuples.
› dbms › relational_data_model
What is the subquery?
A subquery is a query that appears inside another query statement. Subqueries are also referred to as sub- SELECT s or nested SELECT s. The full SELECT syntax is valid in subqueries.What are sub query What are different types of sub queries?
If your subquery returns more than one row, it can be referred to as a multiple-row subquery. Note that this subquery type includes (1) subqueries that return one column with multiple rows (i.e. a list of values) and (2) subqueries that return multiple columns with multiple rows (i.e. tables).What is subquery in DBMS?
A subquery is a query that is nested inside a SELECT , INSERT , UPDATE , or DELETE statement, or inside another subquery.How many types of sub queries are there in SQL?
There are three broad divisions of subquery: Single-row subqueries. Multiple-row subqueries. Correlated subqueries.Oracle PL SQL interview question What is SUBQUERY and its types
What is subquery and its properties?
A subquery is also known as a nested query which means query inside another query. A subquery is used to return data that will be used in the main query as a condition to further restrict the data to be retrieved. Properties of Sub-Query A subquery should be boxed within the parenthesis.What is difference between query and subquery?
A query is an operation that retrieves data from one or more tables or views. In this reference, a top-level SELECT statement is called a query, and a query nested within another SQL statement is called a subquery.What is difference between subquery and nested query?
When a query is included inside another query, the Outer query is known as Main Query, and Inner query is known as Subquery. In Nested Query, Inner query runs first, and only once. Outer query is executed with result from Inner query.What are the four different types of results that can be returned from a subquery?
Subqueries can return different types of information:
- A scalar subquery returns a single value.
- A column subquery returns a single column of one or more values.
- A row subquery returns a single row of one or more values.
- A table subquery returns a table of one or more rows of one or more columns.
What is the difference between correlated and uncorrelated subquery?
A correlated subquery can be thought of as a filter on the table that it refers to, as if the subquery were evaluated on each row of the table in the outer query. An uncorrelated subquery has no such external column references.What is subquery answer?
Answer: A.A subquery is a complete query nested in the SELECT, FROM, HAVING, or WHERE clause of another query. The subquery must be enclosed in parentheses and have a SELECT and a FROM clause, at a minimum. A single-row subquery can return a maximum of one value.
What are the types of JOINs?
Types of joins
- Cross join. A cross join returns all possible combinations of rows of two tables (also called a Cartesian product).
- Join/inner join. An inner join, also known as a simple join, returns rows from joined tables that have matching rows. ...
- Left outer join/left join.
- Right outer join/right join.
- Full outer join.
Why do you need subquery?
If you need to combine related information from different rows within a table, then you can join the table with itself. Use subqueries when the result that you want requires more than one query and each subquery provides a subset of the table involved in the query.What is the difference between subquery and join?
A SQL Join statement is used to combine data or rows from two or more tables based on a common field between them. A subquery is a query that is nested inside a SELECT , INSERT , UPDATE , or DELETE statement, or inside another subquery.What is correlated subquery and subquery?
In a SQL database query, a correlated subquery (also known as a synchronized subquery) is a subquery (a query nested inside another query) that uses values from the outer query. Because the subquery may be evaluated once for each row processed by the outer query, it can be slow.What is a subquery Mcq?
d) A subquery is a condition that excludes all the invalid tuples from the database. Explanation: A subquery is a select-from-where expression that is nested within another query. Common uses for sub-queries are to perform tests for set membership, make set comparisons etc.What are the 4 types of database JOINs?
There are four main types of JOINs in SQL: INNER JOIN, OUTER JOIN, CROSS JOIN, and SELF JOIN.What are the 3 types of JOINs in SQL?
Different Types of SQL JOINs
- (INNER) JOIN : Returns records that have matching values in both tables.
- LEFT (OUTER) JOIN : Returns all records from the left table, and the matched records from the right table.
- RIGHT (OUTER) JOIN : Returns all records from the right table, and the matched records from the left table.