MySQL Arithmetic


 

MySQL Arithmetic

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

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

MySQL Arithmetic

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

In this example we use arithmetic operator (+, /, -, *, %).

 

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  |
+-----+

 

Ads