SELECT
and WHERE
Clauses
The usual arithmetic operators are available. Note that in the case of
`-', `+', and `*', the result is calculated with
BIGINT
(64-bit) precision if both arguments are integers!
If one of the argument is an unsigned integer, and the other argument
is also an integer, the result will be an unsigned integer.
See section 6.3.5 Cast Functions.
+
mysql> SELECT 3+5; -> 8
-
mysql> SELECT 3-5; -> -2
*
mysql> SELECT 3*5; -> 15 mysql> SELECT 18014398509481984*18014398509481984.0; -> 324518553658426726783156020576256.0 mysql> SELECT 18014398509481984*18014398509481984; -> 0The result of the last expression is incorrect because the result of the integer multiplication exceeds the 64-bit range of
BIGINT
calculations.
/
mysql> SELECT 3/5; -> 0.60Division by zero produces a
NULL
result:
mysql> SELECT 102/(1-1); -> NULLA division will be calculated with
BIGINT
arithmetic only if performed
in a context where its result is converted to an integer!