SQLite 算術運算符
假設變量A=10和變量B=20,那麼SQLite的算術運算符將用於如下:
運算符 | 描述 | 實例 |
---|---|---|
+ | Addition - Adds values on either side of the operator | a + b will give 30 |
- | Subtraction - Subtracts right hand operand from left hand operand | a - b will give -10 |
* | Multiplication - Multiplies values on either side of the operator | a * b will give 200 |
/ | Division - Divides left hand operand by right hand operand | b / a will give 2 |
% | Modulus - Divides left hand operand by right hand operand and returns remainder | b % a will give 0 |
示例
下麵是簡單的例子顯示使用SQLite的算術運算符:
sqlite> .mode line sqlite> select 10 + 20; 10 + 20 = 30 sqlite> select 10 - 20; 10 - 20 = -10 sqlite> select 10 * 20; 10 * 20 = 200 sqlite> select 10 / 5; 10 / 5 = 2 sqlite> select 12 % 5; 12 % 5 = 2