Skip to main content

Arithmetic Operators

Arithmetic Operators.

Syntax

OperatorSyntaxDescription
+ (unary)+aReturns a.
+a + bAdds two numeric expressions.
- (unary)-aNegates the numeric expression.
-a - bSubtract two numeric expressions.
*a * bMultiplies two numeric expressions.
/a / bDivides one numeric expression (a) by another (b).
%a % bComputes the modulo of numeric expression.

Examples

SELECT +2;
+------+
| 2 |
+------+
| 2 |
+------+

SELECT 5+2;
+---------+
| (5 + 2) |
+---------+
| 7 |
+---------+

SELECT -2;
+------+
| -2 |
+------+
| -2 |
+------+

SELECT 5-2;
+---------+
| (5 - 2) |
+---------+
| 3 |
+---------+

SELECT 5*2;
+---------+
| (5 * 2) |
+---------+
| 10 |
+---------+

SELECT 5/2;
+---------+
| (5 / 2) |
+---------+
| 2.5 |
+---------+

SELECT 5%2;
+---------+
| (5 % 2) |
+---------+
| 1 |
+---------+