Subqueries in expressions

A SELECT statement that is nested inside another SELECT statement.

Syntax

A subquery is structured like a regular query.

Remarks

In UltraLite, you can only use subquery references in the following situations:

  • As a table expression in the FROM clause. This form of table expression (also called derived tables) must have a derived table name and column names in which values in the SELECT list are fetched.
  • To supply values for the EXISTS, ANY, ALL, and IN search conditions.

You can write subqueries with references to names that are specified before (to the left of) the subquery, sometimes known as outer references to the left. However, you cannot have references to items within subqueries (sometimes known as inner references).

See also
Example

The following subquery is used to list all product IDs for items that are low in stock (that is, less than 20 items).

FROM SalesOrderItems
 ( SELECT ID
   FROM Products
   WHERE Quantity < 20 );