Specifications
TABLE 9.1 Useful Comparison Operators for WHERE Clauses
Operator Name Example Description
(If Applicable)
= equality customerid = 3 Tests whether two values are equal
> greater than amount > 60.00 Tests whether one value is greater
than another
< less than amount < 60.00 Tests whether one value is less than
another
>= greater than amount >= 60.00 Tests whether one value is greater
or equal than or equal to another
<= less than or amount <= 60.00 Tests whether one value is less than
equal or equal to another
!= or <> not equal quantity != 0 Tests whether two values are not
equal
IS NOT address is not Tests whether field actually
NULL null contains a value
IS NULL address is null Tests whether field does not contain
a value
BETWEEN amount between Tests whether a value is greater or
0 and 60.00 equal to a minimum value and less
than or equal to a maximum value
IN city in Tests whether a value is in a
(“Carlton”, “Moe”) particular set
NOT IN city not in Tests whether a value is not in
(“Carlton”, a set
“Moe”)
LIKE pattern match name like Checks whether a value matches
(“Fred %”) a pattern using simple SQL pattern
matching
NOT LIKE pattern match name not like Checks whether a value doesn’t
(“Fred %”) match a pattern
REGEXP regular name regexp Checks whether a value matches a
expression regular expression
The last three lines in the table refer to LIKE and REGEXP. These are both forms of pattern
matching.
Working with Your MySQL Database
C
HAPTER 9
9
W
ORKING WITH
YOUR MYSQL
DATABASE
213
12 7842 CH09 3/6/01 3:36 PM Page 213