Jump to: navigation, search

Mysql operator PLUS

From w3cyberlearnings

Contents

MySQL Addition Function

Add two numbers and return result

Syntax Addition

  • N is the first number
  • M is the second number
N + M 

Example 1

mysql> SELECT 43+7;
+------+
| 43+7 |
+------+
|   50 | 
+------+
1 row in set (0.00 sec)

Example 2

mysql> SELECT * FROM totalearn;
+----+------------+-------------+
| id | total_hour | hourly_rate |
+----+------------+-------------+
|  1 |         30 |          50 | 
|  2 |         40 |          50 | 
|  3 |         30 |          80 | 
|  4 |         34 |          90 | 
+----+------------+-------------+
4 rows in set (0.00 sec)

mysql> SELECT id, total_hour,
    -> hourly_rate  + 2
    -> FROM totalearn;
+----+------------+------------------+
| id | total_hour | hourly_rate  + 2 |
+----+------------+------------------+
|  1 |         30 |               52 | 
|  2 |         40 |               52 | 
|  3 |         30 |               82 | 
|  4 |         34 |               92 | 
+----+------------+------------------+
4 rows in set (0.00 sec)

Related Links

# Function Description
1 DIV Integer division
2 / Division operator
3 - Minus operator
4 % or MOD Modulo operator
5 + Addition operator
6 * Multiplication operator
7 - Change the sign of the argument
Navigation
Web
SQL
MISC
References