Tutorials

MySQL Arithmetic

Arithmetic operators are used to perform mathematical operations on two expressions to negate, add, subtract, multiply, and divide numeric values.

Arithmetic operators are used to perform mathematical operations on two expressions to negate, add, subtract, multiply, and divide numeric values.

MySQL Arithmetic

This example illustrates how to use arithmetic operator in the MySQL.

Arithmetic operators are used to perform mathematical operations on two expressions to negate, add, subtract, multiply, and divide numeric values. In this example we use arithmetic operators +, /, -, * and  %.

SQL Arithmetic Operators:

 `Operator` `Definition` `+` `Addition` `-` `Subtraction` `*` `Multiplication` `/` `Division` `%` `Modulus`

Examples:

 `Query` `Output` `select 3+5;` ```+-----+ | 3+5 | +-----+ | 8 | +-----+``` `select 5/3;` ```+--------+ | 5/3 | +--------+ | 1.6667 | +--------+``` `select 3-5;` ```+-----+ | 3-5 | +-----+ | -2 | +-----+``` `select 3%5;` ```+-----+ | 3%5 | +-----+ | 3 | +-----+``` `select 20%5;` ```+------+ | 20%5 | +------+ | 0 | +------+``` `select 3*5;` ```+-----+ | 3*5 | +-----+ | 15 | +-----+```