Database Reference
In-Depth Information
The query results appear in Figure 3-7.
79
Customers with credit
limits of $10,000
FIGURE 3-7
Query results
The WHERE clause shown in Figure 3-6 includes a simple condition. A simple condition includes the
field name, a comparison operator, and either another field name or a value, such as CreditLimit
10000 or
¼
CreditLimit
Balance. Figure 3-8 lists the comparison operators that you can use in SQL commands. Notice
that there are two versions of the
>
. You must use the correct one for
your version of SQL. If you use the wrong one, your system will generate an error, in which case, you
not equal to
operator:
and !
<>
¼
'
ll know
to use the other version.
Comparison Operator
Meaning
=
Equal to
<
Less than
>
Greater than
<=
Less than or equal to
>=
Greater than or equal to
< >
Not equal to (used by most implementations of SQL)
!=
Not equal to (used by some implementations of SQL)
FIGURE 3-8
Comparison operators used in SQL commands
In Example 4, the WHERE clause compared a numeric field (CreditLimit) to a number (10000). When a
query involves a character field, such as CustomerNum or CustomerName, you must enclose the value to
which the field is being compared in single quotation marks, as illustrated in Examples 5 and 6.
EXAMPLE 5
Find the name of customer 148.
The query design appears in Figure 3-9. Because CustomerNum is a character field, the value 148 is
enclosed in single quotation marks.
Search WWH ::




Custom Search