0% found this document useful (0 votes)
10 views23 pages

1.1 Subqueries IN WHERE PDF

The document discusses SQL subqueries, which are inner queries embedded within an outer query. It explains that subqueries can return various outputs and can be nested within each other, with the SQL engine executing the innermost query first. Additionally, it emphasizes that subqueries should be enclosed in parentheses and can be used multiple times within an outer query.

Uploaded by

ablearnfr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views23 pages

1.1 Subqueries IN WHERE PDF

The document discusses SQL subqueries, which are inner queries embedded within an outer query. It explains that subqueries can return various outputs and can be nested within each other, with the SQL engine executing the innermost query first. Additionally, it emphasizes that subqueries should be enclosed in parentheses and can be used multiple times within an outer query.

Uploaded by

ablearnfr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

SQL Subqueries

SQL Subqueries with IN Nested Inside WHERE


SQL Subqueries with IN Nested Inside WHERE

subqueries
queries embedded in a query
SQL Subqueries with IN Nested Inside WHERE

subqueries
SQL Subqueries with IN Nested Inside WHERE

subqueries

queries embedded in a query


SQL Subqueries with IN Nested Inside WHERE

subqueries = inner queries

queries embedded in a query


SQL Subqueries with IN Nested Inside WHERE

subqueries = inner queries = nested queries

queries embedded in a query


SQL Subqueries with IN Nested Inside WHERE

subqueries = inner queries = nested queries

queries embedded in a query

- they are part of another query, called an outer query


SQL Subqueries with IN Nested Inside WHERE

subqueries = inner queries = nested queries = inner select

queries embedded in a query

- they are part of another query, called an outer query


SQL Subqueries with IN Nested Inside WHERE

subqueries = inner queries = nested queries = inner select

queries embedded in a query

- they are part of another query, called an outer query

= outer select
SQL Subqueries with IN Nested Inside WHERE

_dup
SQL Subqueries with IN Nested Inside WHERE

subqueries
SQL Subqueries with IN Nested Inside WHERE

subqueries
- a subquery should always be placed within parentheses
SQL Subqueries with IN Nested Inside WHERE
1) the SQL engine starts by running the inner query
SQL Subqueries with IN Nested Inside WHERE
1) the SQL engine starts by running the inner query

2) then it uses its returned output, which is intermediate, to execute


the outer query
SQL Subqueries with IN Nested Inside WHERE

a subquery may return a single value (a scalar), a single row, a


single column, or an entire table
SQL Subqueries with IN Nested Inside WHERE

_dup
SQL Subqueries with IN Nested Inside WHERE

a subquery may return a single value (a scalar), a single row, a


single column, or an entire table
SQL Subqueries with IN Nested Inside WHERE

a subquery may return a single value (a scalar), a single row, a


single column, or an entire table

- you can have a lot more than one subquery in your outer query
SQL Subqueries with IN Nested Inside WHERE

a subquery may return a single value (a scalar), a single row, a


single column, or an entire table

- you can have a lot more than one subquery in your outer query
- it is possible to nest inner queries within other inner queries
SQL Subqueries with IN Nested Inside WHERE

a subquery may return a single value (a scalar), a single row, a


single column, or an entire table

- you can have a lot more than one subquery in your outer query
- it is possible to nest inner queries within other inner queries

in that case, the SQL engine would execute the innermost query
first
SQL Subqueries with IN Nested Inside WHERE

a subquery may return a single value (a scalar), a single row, a


single column, or an entire table

- you can have a lot more than one subquery in your outer query
- it is possible to nest inner queries within other inner queries

in that case, the SQL engine would execute the innermost query
first, and then each subsequent query
SQL Subqueries with IN Nested Inside WHERE

a subquery may return a single value (a scalar), a single row, a


single column, or an entire table

- you can have a lot more than one subquery in your outer query
- it is possible to nest inner queries within other inner queries

in that case, the SQL engine would execute the innermost query
first, and then each subsequent query, until it runs the outermost
query last

You might also like