602SQL Documentation Index  


SQL allows a query phrase to be a part of another general expression or a generalized table. This query phrase is simply called a subquery. A subquery must be enclosed in parenthesis. A subquery may be a complete query phrase including other nested subqueries. The LIMIT clause may be used in subqueries (usually together with ORDER BY).

Subqueries can be divided according to various criteria. There are three types based on the number of rows and columns:

A subquery may be used in a query phrase located in the SELECT, FROM and WHERE parts. The usage of subqueries is not restricted to query phrases only. They can be used in many other constructions, for example:

IF EXISTS (SELECT admin_enabled FROM System 
           WHERE (admin_name=usr)AND(admin_password=pwd)AND(admin_enabled IS TRUE)) 
  THEN ...