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



MySQL Arithmetic
Posted on: October 6, 2010 By Deepak Kumar
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  |
+-----+

Recommend the tutorial

Ask Questions?    Discuss: MySQL Arithmetic  

Post your Comment


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