Jump to: navigation, search

Mysql operator MINUS

From w3cyberlearnings

Contents

MySQL MINUS operator Function

Returns first number minus the second number

Syntax MINUS operator

N1-N2

Example 1

mysql> SELECT 50-40;
+-------+
| 50-40 |
+-------+
|    10 | 
+-------+
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-10 as reduce_rate
    -> FROM totalearn;
+----+------------+-------------+
| id | total_hour | reduce_rate |
+----+------------+-------------+
|  1 |         30 |          40 | 
|  2 |         40 |          40 | 
|  3 |         30 |          70 | 
|  4 |         34 |          80 | 
+----+------------+-------------+
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