Comparison Functions and Operators
874
Operator precedences are shown in the following list, from highest precedence to the lowest. Operators
that are shown together on a line have the same precedence.
INTERVAL
BINARY, COLLATE
!
- (unary minus), ~ (unary bit inversion)
^
*, /, DIV, %, MOD
-, +
<<, >>
&
|
= (comparison), <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN
BETWEEN, CASE, WHEN, THEN, ELSE
NOT
&&, AND
XOR
||, OR
= (assignment), :=
The precedence of
=
depends on whether it is used as a comparison operator (
=
[875]
) or as an
assignment operator (
=
[882]
). When used as a comparison operator, it has the same precedence
as
<=>
[876]
,
>=
[876]
,
>
[876]
,
<=
[876]
,
<
[876]
,
<>
[876]
,
!=
[876]
,
IS
[876]
,
LIKE
[896]
,
REGEXP
[899]
, and
IN
[878]
. When used as an assignment operator, it has the same
precedence as
:=
[881]
.
Section 13.7.4, “
SET
Syntax”
, and
Section 9.4, “User-Defined Variables”
,
explain how MySQL determines which interpretation of
=
should apply.
The meaning of some operators depends on the SQL mode:
• By default,
||
[881]
is a logical
OR
[881]
operator. With
PIPES_AS_CONCAT
[539]
enabled,
||
[881]
is string concatenation, with a precedence between
^
[951]
and the unary operators.
• By default,
!
[880]
has a higher precedence than
NOT
as of MySQL 5.0.2. For earlier versions,
or from 5.0.2 on with
HIGH_NOT_PRECEDENCE
[536]
enabled,
!
[880]
and
NOT
have the same
precedence.
See
Section 5.1.7, “Server SQL Modes”
.
The precedence of operators determines the order of evaluation of terms in an expression. To override
this order and group terms explicitly, use parentheses. For example:
mysql>
SELECT 1+2*3;
-> 7
mysql>
SELECT (1+2)*3;
-> 9
12.3.2. Comparison Functions and Operators
Table 12.3. Comparison Operators
Name
Description
BETWEEN ... AND ...
[877]
Check whether a value is within a range of values
COALESCE()
[878]
Return the first non-NULL argument
<=>
[876]
NULL-safe equal to operator
=
[875]
Equal operator
>=
[876]
Greater than or equal operator
>
[876]
Greater than operator
GREATEST()
[878]
Return the largest argument
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...