mysql存储过程学习总结-操作符
算术运算符
+ 加 SET var1=2+2; 4
- 减 SET var2=3-2; 1
*乘 SET var3=3*2; 6
/ 除 SET var4=10/3; 3.3333
DIV 整除SET var5=10 DIV 3; 3
% 取模SET var6=10%3 ; 1
比较运算符
> 大于1>2False
< 小于2<1False
<= 小于等于2<=2True
>= 大于等于3>=2True
BETWEEN 在两值之间5 BETWEEN 1 AND 10True
NOT BETWEEN 不在两值之间5 NOT BETWEEN 1 AND 10False
IN 在集合中5 IN (1,2,3,4)False
NOT IN 不在集合中5 NOT IN (1,2,3,4)True
=等于2=3False
<>, != 不等于2<>3False
<=> 严格比较两个NULL值是否相等NULL<=>NULLTrue
LIKE简单模式匹配"Guy Harrison" LIKE "Guy%"True
REGEXP 正则式匹配"Guy Harrison" REGEXP "[Gg]reg"False
IS NULL 为空0 IS NULLFalse
IS NOT NULL 不为空0 IS NOT NULLTrue
< 小于2<1False
<= 小于等于2<=2True
>= 大于等于3>=2True
BETWEEN 在两值之间5 BETWEEN 1 AND 10True
NOT BETWEEN 不在两值之间5 NOT BETWEEN 1 AND 10False
IN 在集合中5 IN (1,2,3,4)False
NOT IN 不在集合中5 NOT IN (1,2,3,4)True
=等于2=3False
<>, != 不等于2<>3False
<=> 严格比较两个NULL值是否相等NULL<=>NULLTrue
LIKE简单模式匹配"Guy Harrison" LIKE "Guy%"True
REGEXP 正则式匹配"Guy Harrison" REGEXP "[Gg]reg"False
IS NULL 为空0 IS NULLFalse
IS NOT NULL 不为空0 IS NOT NULLTrue
逻辑运算符
与(AND)
<meta content="text/html; charset=utf-8" http-equiv="CONTENT-TYPE">
<meta content="OpenOffice.org 2.0 (Linux)" name="GENERATOR"> <meta content="20061101;13545200" name="CREATED"> <meta content="16010101;0" name="CHANGED"> <style type="text/css"> <!-- @page { size: 8.5in 11in; margin: 0.79in } TD P { margin-bottom: 0in } TH P { margin-bottom: 0in; font-style: italic } P { margin-bottom: 0.08in } --> </style> AND | TRUE | FALSE | NULL |
---|---|---|---|
TRUE | TRUE | FALSE | NULL |
FALSE | FALSE | FALSE | NULL |
NULL | NULL | NULL | NULL |
或(OR)
<style type="text/css"> <!-- @page { size: 8.5in 11in; margin: 0.79in } TD P { margin-bottom: 0in } TH P { margin-bottom: 0in; font-style: italic } P { margin-bottom: 0.08in } --> </style>
OR | TRUE | FALSE | NULL |
---|---|---|---|
TRUE | TRUE | TRUE | TRUE |
FALSE | TRUE | FALSE | NULL |
NULL | TRUE | NULL | NULL |
异或(XOR)
<style type="text/css"> <!-- @page { size: 8.5in 11in; margin: 0.79in } TD P { margin-bottom: 0in } TH P { margin-bottom: 0in; font-style: italic } P { margin-bottom: 0.08in } --> </style>
XOR | TRUE | FALSE | NULL |
---|---|---|---|
TRUE | FALSE | TRUE | NULL |
FALSE | TRUE | FALSE | NULL |
NULL | NULL | NULL | NULL |
位运算符
| 位或
& 位与
<< 左移位
>> 右移位
~ 位非(单目运算,按位取反)