MySQL Arithmetic and comparison operators
Table 3-2 shows examples of the basic arithmetic and comparison operators in
SELECT statements. The basic arithmetic operators are
-, as well as the parentheses
( ) to control the order of evaluation of an expression.
Examples using the arithmetic and comparison operators
The comparison operators include
>=. Four examples are shown in Table 3-2. If an expression evaluates as
true, the output is 1; if an expression evaluates as
false, the output is 0. To test for equality, a single equals sign is used; this contrasts with PHP, where the double equals (
==) is used for equality tests, and a single equals sign is used for assignment.
To test whether two items are equal, the
!= operator is provided. Less-than-or-equal-to is represented by
<=, and greater-than-or-equal-to is represented by
>=. Parentheses can explicitly express the evaluation order.