To retrieve data from a table, the table is
queried. An SQLSELECT statement
is used to do this. The statement is divided into a select list
(the part that lists the columns to be returned), a table list
(the part that lists the tables from which to retrieve the data),
and an optional qualification (the part that specifies any
restrictions). For example, to retrieve all the rows of table
weather, type:

SELECT * FROM weather;

Here * is a shorthand for
"all columns". [1]
So the same result would be had with:

Notice how the AS clause is used to
relabel the output column. (The AS
clause is optional.)

A query can be "qualified" by
adding a WHERE clause that specifies
which rows are wanted. The WHERE clause
contains a Boolean (truth value) expression, and only rows for
which the Boolean expression is true are returned. The usual
Boolean operators (AND, OR, and NOT) are allowed
in the qualification. For example, the following retrieves the
weather of San Francisco on rainy days:

Notes

In some database systems, including older versions of
PostgreSQL, the
implementation of DISTINCT
automatically orders the rows and so ORDER BY is unnecessary. But this is not
required by the SQL standard, and current PostgreSQL doesn't guarantee that
DISTINCT causes the rows to be
ordered.