SQL Operators
So
far,
we have used the = operator for the obvious task
of verifying that two values in a WHERE clause
equal one another. Other fairly basic operations include
<>, >,
<, <=, and
>=. Note that MySQL allows you to use either
<> or != for
“not equal.” Table 3-6 contains a full set of simple SQL operators.
|
Operator |
Context |
Description |
|
|
Arithmetic |
Addition |
|
|
Arithmetic |
Subtraction |
|
|
Arithmetic |
Multiplication |
|
|
Arithmetic |
Division |
|
|
Comparison |
Equal |
|
|
Comparison |
Not equal |
|
|
Comparison |
Less than |
|
|
Comparison |
Greater than |
|
|
Comparison |
Less than or equal to |
|
|
Comparison |
Greater than or equal to |
|
|
Logical |
And |
|
|
Logical |
Or |
|
|
Logical |
Negation |
MySQL operators have the following order of precedence:
BINARYNOT !-(unary minus)* / %+ -<< >>&|< <= > >= = <=> <> IN IS LIKE REGEXP RLIKEBETWEENAND &&OR ||
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access