Computer Science, asked by p1998p, 1 year ago

What is Subquery?What are the types of Subquery?

(don't copy from google)

Answers

Answered by p1998
1
A subquery is a query that is nested inside a SELECT, INSERT, UPDATE, or DELETE statement, or inside another subquery. A subquery can be used anywhere an expression is allowed. In this example a subquery is used as a column expression named MaxUnitPrice in a SELECT statement.

Types of Subqueries
In terms of the placement of the subquery, there are three types:

1. Nested Subquery: The subquery appears in the WHERE clause of the SQL.

2. Inline View: The subquery appears in the FROM clause of the SQL.

3. Scalar Subquery: The subquery appears in the SELECT clause of the SQL.

In terms of the way the subquery is parsed, there are two categories of subqueries:

1. Simple Subquery: This is the kind we saw above. A simple subquery is evaluated once only for each table.

2. Correlated Subquery: This is a type of nested subquery that uses columns from the outer query in its WHERE clause. A correlated subquery is evaluated once for each row.
Similar questions