A subquery is a SELECT
statement that is embedded in a clause of another SELECT
statement. A subquery can be placed in WHERE HAVING
and FROM
clause.
Guidelines for using subqueries :
* Enclose sub queries within parenthesis
* Place subqueries on the right side of the comparison condition.
* Use Single-row operators with single-row subqueries and Multiple-row operators with multiple-row subqueries.
Types of subqueries :
* Single-Row Subquery : Queries that return only one row from the inner select statement. Single-row comparison operators are: =, >, >=, <, <=, <>
* Multiple-Row Subquery : Queries that return more than one row from the inner Select statement. There are also multiple-column subqueries that return more than one column from the inner select statement. Operators include: IN, ANY, ALL.