2.1.4 Querying a Table

Table of Contents Previous Next


2 SQL Tutorial : 2.1 Getting Started : 2.1.4 Querying a Table

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.
Notice how the AS clause is used to re-label 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 employees in department 20 with salaries over $1000.00:

2 SQL Tutorial : 2.1 Getting Started : 2.1.4 Querying a Table

Table of Contents Previous Next