This statement restricts the data returned by comparing the data in the table against the conditions specified in the WHERE clause.
SELECT * FROM tablename WHERE fieldname-expression [AND|OR fieldname-expression]
tablename
The name of the table from which to retrieve data.
fieldname-expression
Can take one of the following forms:
· [NOT] fieldname operator constant
· fieldname IS [NOT] NULL
· fieldname IS [NOT] TRUE
· fieldname IS [NOT] FALSE
· fieldname [NOT] LIKE “string%”
|
Value |
Description | |
|
fieldname |
The name of a field in the table to use in a comparison
operation. | |
|
operator |
The type of operation performed. Can be one of the following
values: | |
|
|
Operator |
Description |
|
|
= |
Equal* |
|
|
> |
Greater than |
|
|
>= |
Greater than or equal |
|
|
< |
Less than |
|
|
<= |
Less than or equal |
|
|
<> |
Not equal* |
|
constant |
A numeric string or date, enclosed by quotation marks. | |
|
string% |
A string constant followed by the percent (%) or asterisk
(*) wildcard character. A wildcard character can also be used by itself to
match everything. Use a wildcard character only at the end of the string
constant. | |
*. This operator produces an error when used with floating-point data types.
An error results if an SQL statement uses the equal operator (=) or the not equal (<>) operator to compare floating-point data types.
You can use parentheses to group expressions and establish precedence.
The following additional rules apply to the WHERE statement: