Share on Google+Share on Google+

MySQL Arithmetic

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

 

Advertisements

Advertisement

Posted on: December 9, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.