SELECT


The SELECT statement retrieves data from the database. It is a very powerful and complex statement. This document breaks down its syntax and examines each clause on a separate page:
  SELECT [predicate] * | fieldlist
  FROM tablespec
   [WHERE wherepredicate]
   [GROUP BY groupfieldlist
    [HAVING havingpredicate]]
   [ORDER BY orderfieldlist]

The purpose of each part is summarized below:
Part Purpose
 * Specifies that all possible data columns are returned.
predicate Restricts the data rows returned, e.g. to avoid duplicates
fieldlist The list of fields returned by the query
tablespec Specifies the tables that contain the data, together with the necessary inter-table relationships.
wherepredicate Specifies one or more conditions that must be true for each returned data row
groupfieldlist Specifies grouping for the returned data.
havingpredicate Specified one or more conditions that must be true for each returned data group
orderfieldlist Specifies the data's order within each group.




[Return to SQL Syntax]