MySQL Tutorial/Introduction/Operator — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 13:44, 26 мая 2010
Operator
Name Description AND, && Logical AND BINARY Cast a string to a binary string & Bitwise AND | Bitwise OR ^ Bitwise XOR / Division operator DIV Integer division <=> NULL-safe equal to operator = Equal operator >= Greater than or equal operator > Greater than operator IS NULL NULL value test IS Test a value against a boolean << Left shift <= Less than or equal operator < Less than operator LIKE Simple pattern matching - Minus operator % Modulo operator !=, <> Not equal operator NOT LIKE Negation of simple pattern matching NOT REGEXP Negation of REGEXP NOT, ! Negates value ||, OR Logical OR + Addition operator REGEXP Pattern matching using regular expressions >> Right shift RLIKE Synonym for REGEXP SOUNDS LIKE Compare sounds ~ Invert bits
Times operator - Change the sign of the argument XOR Logical XOR
Operator precedences
Operator precedences are shown in the following list, from lowest precedence to the highest.
Operators that are shown together on a line have the same precedence.
- :=
- ||, OR, XOR
- &&, AND
- NOT
- BETWEEN, CASE, WHEN, THEN, ELSE
- =, <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN
- |
- &
- <<, >>
- -, +
- *, /, DIV, %, MOD
- ^
- - (unary minus), ~ (unary bit inversion)
- !
- BINARY, COLLATE
1. 4. Operator 1. 4. 1. <A href="/Tutorial/MySQL/0020__Introduction/Operator.htm">Operator</a> 1. 4. 2. Operator precedences 1. 4. 3. <A href="/Tutorial/MySQL/0020__Introduction/Tooverridethisorderandgrouptermsexplicitlyuseparentheses.htm">To override this order and group terms explicitly, use parentheses.</a>
To override this order and group terms explicitly, use parentheses.
mysql>
mysql> SELECT 1+2*3;
+-------+
| 1+2*3 |
+-------+
| 7 |
+-------+
1 row in set (0.00 sec)
mysql>
mysql> SELECT (1+2)*3;
+---------+
| (1+2)*3 |
+---------+
| 9 |
+---------+
1 row in set (0.00 sec)
mysql>
mysql>