Entering content frame

 Scalar Subquery (scalar_subquery) 

A scalar subquery (scalar_subquery) is a special subquery.

Syntax

<scalar_subquery> ::= <subquery>

subquery

Explanation

Scalar subqueries are produced through the restriction of the result set of a result table to a maximum of one value.

Scalar subqueries can be used as expressions (see factor).

Scalar subqueries are not allowed in a GROUP clause or an ORDER clause.

Scalar subquery in the list of the values to be inserted in an INSERT statement for the table hotel:

INSERT hotel VALUES((SELECT MAX(hno)+10 FROM hotel), 'Three Seasons', 90014, 'Los Angeles', '247 Broad Street')

Scalar subquery in a selected column:

SELECT hno, price, (SELECT MIN(price) FROM room) FROM room

 

Leaving content frame