Comparison Functions and Operators
879
•
expr NOT IN (value,...)
[879]
This is the same as
NOT (expr IN (value,...))
.
•
ISNULL(expr)
[879]
If
expr
is
NULL
,
ISNULL()
[879]
returns
1
, otherwise it returns
0
.
mysql>
SELECT ISNULL(1+1);
-> 0
mysql>
SELECT ISNULL(1/0);
-> 1
ISNULL()
[879]
can be used instead of
=
[875]
to test whether a value is
NULL
. (Comparing a
value to
NULL
using
=
[875]
always yields false.)
The
ISNULL()
[879]
function shares some special behaviors with the
IS NULL
[877]
comparison operator. See the description of
IS NULL
[877]
.
•
INTERVAL(N,N1,N2,N3,...)
[879]
Returns
0
if
N
<
N1
,
1
if
N
<
N2
and so on or
-1
if
N
is
NULL
. All arguments are treated as integers. It
is required that
N1
<
N2
<
N3
<
...
<
Nn
for this function to work correctly. This is because a binary
search is used (very fast).
mysql>
SELECT INTERVAL(23, 1, 15, 17, 30, 44, 200);
-> 3
mysql>
SELECT INTERVAL(10, 1, 10, 100, 1000);
-> 2
mysql>
SELECT INTERVAL(22, 23, 30, 44, 200);
-> 0
•
LEAST(value1,value2,...)
[879]
With two or more arguments, returns the smallest (minimum-valued) argument. The arguments are
compared using the following rules:
• If the return value is used in an
INTEGER
context or all arguments are integer-valued, they are
compared as integers.
• If the return value is used in a
REAL
context or all arguments are real-valued, they are compared
as reals.
• If the arguments comprise a mix of numbers and strings, they are compared as numbers.
• If any argument is a nonbinary (character) string, the arguments are compared as nonbinary
strings.
• In all other cases, the arguments are compared as binary strings.
Before MySQL 5.0.13,
LEAST()
[879]
returns
NULL
only if all arguments are
NULL
. As of 5.0.13, it
returns
NULL
if any argument is
NULL
.
mysql>
SELECT LEAST(2,0);
-> 0
mysql>
SELECT LEAST(34.0,3.0,5.0,767.0);
-> 3.0
mysql>
SELECT LEAST('B','A','C');
-> 'A'
Note that the preceding conversion rules can produce strange results in some borderline cases:
mysql>
SELECT CAST(LEAST(3600, 9223372036854775808.0) as SIGNED);
-> -9223372036854775808
Содержание 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 ...