oracle database study notes (seven)

Chapter VII nested queries (subqueries)

1. What is a nested query?
Further one or more embedded select a query in SQL command.

Queries Ngao and in the same department employee id, last_name?
the above mentioned id the SELECT, last_name
from s_emp
the WHERE dept_id = (the SELECT dept_id
from s_emp
the WHERE last_name = 'Ngao');

sub-query: Query Ngao department id?
the dept_id SELECT
from s_emp
WHERE last_name = 'Ngao'

2. Classification subquery
1) single-value subquery
to a select query as a single-valued use.
Requirements: The results of the subquery must be only one field,
and the field has only one value.
2) multi-value subquery
a) as a result of the sub-array using a query.
Requirements: sub-query results must be only one field.
There can be any number of field values.
b) as a result handle the query table to use.
no limit.

3. Note
1) sub-query does not need to end with a semicolon
2) sub-queries need to put () inside.


Guess you like

Origin www.cnblogs.com/DennySmith/p/12189221.html