Home Sql Mysql-example MySQL Arithmetic
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

MySQL Arithmetic

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

Liked it!  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.

Posted on: October 6, 2010

Ask Questions?    Discuss: MySQL Arithmetic  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com