以下是一些SQL算術運算子用法的簡單範例 -
範例1 - 加法運算 -
mysql> select 10 + 20;
+-------+
| 10 + 20 |
+-------+
| 30 |
+-------+
1 row in set
範例2 - 乘法運算 -
mysql> select 10 * 20;
+---------+
| 10 * 20 |
+---------+
| 200 |
+---------+
1 row in set
範例3 - 除法運算 -
mysql> select 10 / 5;
+--------+
| 10 / 5 |
+--------+
| 2 |
+--------+
1 row in set
範例4 - 求餘運算 -
mysql> select 14 % 5;
+---------+
| 14 % 5 |
+---------+
| 4 |
+---------+
1 row in set