赞
踩
加法(+)、减法(-)、乘法(*)、除法(/)(若除0则返回null)、取余(%)
SELECT 10 + 5 AS Addition, 10 - 5 AS Subtraction, 10 * 5 AS Multiplication, 10 / 5 AS Division;
等于(=)(不可以进行null的比较返回null)、
安全等于()(可以进行null的比较)、
大于(>)、小于(=)、小于等于(/!=)、
IN、NOT IN、BETWEEN AND、
IS NULL(ISNULL)、IS NOT NULL、
最大值(GREATEST)、最小值(LEAST)、
LIKE、正则(REGEXP)等。
SELECT 10 = 10 AS a, 10 != 5 AS b, 10 > 5 AS c, 10 < 5 AS d;
逻辑非(NOT/!)、逻辑与(AND/&&)、逻辑或(OR/||)、逻辑异或(XOR)
- SELECT (10 > 5) AND (10 < 15) AS a, (10 > 5) OR (10 < 5) AS b,
- NOT (10 = 5) AS c, (10 = 5) XOR (10 > 5) AS d;
按位或(|)、按位与(&)、按位异或(^)、按位左移(>)、按位取反(~)
SELECT 10 & 3 AS a, 10 | 3 AS b, 10 ^ 3 AS c, ~10 AS d, 10 << 2 AS e;
用于变量赋值。
- SET @var = 10;
- SET @var := 10;
- SELECT @var := @var + 1 AS a;
当一个表达式中包含多种运算时,某些运算符的优先级高于其他运算符。
SELECT 10 + 1 * 2 AS a, (10 + 1) * 2 AS b;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。