MySQL Tutorial/Introduction/Operator — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (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.

  1. :=
  2. ||, OR, XOR
  3. &&, AND
  4. NOT
  5. BETWEEN, CASE, WHEN, THEN, ELSE
  6. =, <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN
  7. |
  8. &
  9. <<, >>
  10. -, +
  11. *, /, DIV, %, MOD
  12. ^
  13. - (unary minus), ~ (unary bit inversion)
  14. !
  15. 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>