Databases Reference
In-Depth Information
The query results appear in Figure 3-6.
77
Customers with credit
limits of $10,000
FIGURE 3-6 Query results
Figure 3-5 is called 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-7 lists the
comparison operators that you can use in SQL commands. Notice that there are two versions of the “not equal to”
operator: < > and !=. You must use the correct one for your version of SQL. If you use the wrong one, your sys-
tem will generate an error, in which case, you'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-7 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-8. Because CustomerNum is a character field, the value 148 is
enclosed in single quotation marks.
 
Search WWH ::




Custom Search