To retrieve data from a table, the table is queried
. An SQL SELECT
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). The following query lists all columns of all employees in the table in no particular order.
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
, and NOT
) are allowed in the qualification. For example, the following retrieves the employees in department 20 with salaries over $1000.00: