Database Reference
In-Depth Information
5
Filtering Rows
In this chapter:
How do you filter rows out of a query?
What are conditional comparisons?
What are logical operators?
This chapter extends the syntax of the SELECT statement by examining
WHERE clause filtering, conditional comparisons, and logical operators.
Filtering
is a process of retrieving a subset of the rows retrieved by the
SELECT statement.
5.1
WHERE Clause Syntax
We saw two of the primary parts (or clauses) of an SQL query in the previ-
ous chapter, namely the SELECT clause and the FROM clause. This chap-
ter adds the WHERE clause. Here is a quick description of each clause:
SELECT
. List all the columns you want to see in your report here.
Separate them with commas. Use an asterisk (*) instead of a list of
columns to automatically show all columns in the queried table.
FROM
. Put the table name here. Use an alias for easier referencing in
the SELECT and WHERE clauses.
WHERE (optional)
. Adds conditions that filter out rows. Use vari-
ous comparison conditions and logical operators between each filter.
A query without a WHERE clause returns all rows.
Search WWH ::




Custom Search