I have always been adhering to a point: through their hands real operation after the information is the most reliable, so in your reference to this small time please do not just "see", a simple look is not the truth drop ~ ~ ~
Motto: Paper on the end feel shallow, know this matter to preach!
1. Arithmetic operator Add
Mysql> Select 1+2;
Reducing
Mysql> Select 2-1;
By
Mysql> Select 2*3;
Except
Mysql> Select 5/3;
Business
Mysql> SELECT 5 DIV 2;
Mode
Mysql> Select 5%2,mod (5,2);
2. Comparison operators Equals
Mysql> Select 1=0,1=1,null=null;
Not equal to
Mysql> Select 1<>0,1<>1,null<>null;
Security equals
Mysql> Select 1<=>1,2<=>0,0<=>0,null<=>null;
Less than
Mysql> Select ' A ' < ' B ', ' A ' < ' a ', ' a ' < ' C ',1<2;
Less than or equal to
mysql> select ' BDF ' <= ' B ', ' B ' <= ' B ',0<1;
Greater than
Mysql> select ' A ' > ' B ', ' abc ' > ' A ',1>0;
Greater than or equal to
Mysql> select ' A ' >= ' B ', ' abc ' >= ' A ',1>=0,1>=1;
BETWEEN
Mysql> Select between 9 between and 20;
In
Mysql> Select 1 in (1,2,3), ' t ' in (' t ', ' a ', ' B ', ' l ', ' e '), 0 in (1,2);
Is NULL
Mysql> Select 0 is null,null is null;
is not NULL
Mysql> Select 0 is isn't null, NULL is NOT NULL;
Like
Mysql> select 123456 like ' 123% ', the 123456 like '%123% ', and 123456 like '%321% ';
Regexp
mysql> select ' abcdef ' regexp ' ab ', ' abcdefg ' regexp ' k ';
3. Logical operators Non -
Mysql> Select not 0, not 1, not null;
Mysql> Select! 0,! 1,! Null
And
Mysql> Select (1 and 1), (0 and 1), (3 and 1), (1 and null);
Mysql> Select (1 && 1), (0 && 1), (3 && 1), (1 && null);
Or
Mysql> Select (1 or 0), (0 or 0), (1 or null), (1 or 1), (null or NULL);
Mysql> Select (1 | | 0), (0 | | 0), (1 | | | null), (1 | | 1), (null | | | null);
XOR or
Mysql> Select (1 xor 1), (0 xor 0), (1 XOR 0), (0 XOR 1), (null XOR 1);
Mysql> Select (1 ^ 1), (0 ^ 0), (1 ^ 0), (0 ^ 1), (null ^ 1);
4. Bitwise operators Bit and
Mysql> Select 2&3;
Mysql> Select 2&3&4;
Bit or
Mysql> Select 2|3;
Bit XOR or
Mysql> Select 2^3;
Bit counter
Mysql> Select ~1,~18446744073709551614;
Bit right Shift
Mysql> Select 100>>3;
Left-shift
Mysql> Select 100<<3;
5. Operator Precedence Order Highest priority: =
1 | |, OR, XOR
2 &&, and
3 BETWEEN, Case, when, THEN, ELSE
4 =, <=>, >=, <=, <>,!=, are, like, REGEXP, in
5 |
6 &
7 <<, >>
8-, +
9 *,/, DIV,%, MOD
10 ^
One-(unary minus), ~ (unary bit inversion)
!, not
Lowest priority BINARY, COLLATE
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.