Database Reference
In-Depth Information
Using Comparison Operators
You can use a number of different comparison operators in a WHERE clause (see Table 5-1).
Table 5-1. Comparison Operators
Operator
Description
Example
AddresslD = 1
Equals
<
AddresslD < 1
Less than
>
AddresslD > 1
Greater than
<=
AddresslD <= 1
Less than or equal to
>=
AddresslD >= 1
Greater than or equal to
<>
AddresslD <> 1
Not equal to
!=
AddresslD != 1
Not equal to
!<
AddresslD !< 1
Not less than
!>
AddresslD !> 1
Not greater than
Tip As mentioned earlier, every database vendor has its own implementation of SQL. This discussion is specific
to T-SQL; for example, standard SQL doesn't have the != operator and calls <> the not equals operator. In fact,
standard SQL calls the expressions in a WHERE clause predicates ; we'll use that term because predicates are either
true or false, but other expressions don't have to be. If you work with another version of SQL, please refer to its
documentation for specifics.
You may want to test the comparison operator like in the example, as shown in Figure 5-5.
 
Search WWH ::




Custom Search