Basic Queries  «Prev 

Using the WHERE clause

The following example uses the WHERE clause to get the total number of units in stock for all discontinued products in the Products table.
SELECT SUM([Units In Stock]) AS [Units Remaining]
FROM Products
WHERE (Discontinued = 'True')


This part of the SELECT statement says to select all columns from the CustTable table.
SELECT * FROM CustTable
This part of the SELECT statement says to select all columns from the CustTable table.

The WHERE clause is used to select certain rows that meet a condition.
The WHERE clause is used to select certain rows that meet a condition.

ST is the table column that holds the customer's state. The condition: state equals Arizona.
ST is the table column that holds the customer's state. The condition: state equals Arizona.

The complete statement. This statement will return all columns from rows where state equals Arizona.
SELECT * FROM CustTable
WHERE ST='AZ'
The complete statement. This statement will return all columns from rows where state equals Arizona.