Home Tutorial Php Sql MySQL Arithmetic

 
 

MySQL Arithmetic
Posted on: December 9, 2010 at 12:00 AM
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  |
+-----+

 

Related Tags for MySQL Arithmetic:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.