![background image](http://html1.mh-extra.com/html/oracle/5-0/5-0_reference-manual_1646196897.webp)
Comparison Functions and Operators
877
-> 1, 1, 0
IS NOT boolean_value
[876]
syntax was added in MySQL 5.0.2.
•
IS NULL
[877]
Tests whether a value is
NULL
.
mysql>
SELECT 1 IS NULL, 0 IS NULL, NULL IS NULL;
-> 0, 0, 1
To work well with ODBC programs, MySQL supports the following extra features when using
IS
NULL
[877]
:
• If
sql_auto_is_null
[493]
variable is set to 1 (the default), then after a statement that
successfully inserts an automatically generated
AUTO_INCREMENT
value, you can find that value
by issuing a statement of the following form:
SELECT * FROM
tbl_name
WHERE
auto_col
IS NULL
If the statement returns a row, the value returned is the same as if you invoked the
LAST_INSERT_ID()
[961]
function. For details, including the return value after a multiple-row
insert, see
Section 12.13, “Information Functions”
. If no
AUTO_INCREMENT
value was successfully
inserted, the
SELECT
statement returns no row.
The behavior of retrieving an
AUTO_INCREMENT
value by using an
IS NULL
[877]
comparison
can be disabled by setting
sql_auto_is_null = 0
[493]
. See
Section 5.1.4, “Server System
Variables”
.
• For
DATE
and
DATETIME
columns that are declared as
NOT NULL
, you can find the special date
'0000-00-00'
by using a statement like this:
SELECT * FROM
tbl_name
WHERE
date_column
IS NULL
This is needed to get some ODBC applications to work because ODBC does not support a
'0000-00-00'
date value.
See
Section 20.1.7.1.1, “Obtaining Auto-Increment Values”
, and the description for the
FLAG_AUTO_IS_NULL
option at
Section 20.1.4.2, “Connector/ODBC Connection Parameters”
.
•
IS NOT NULL
[877]
Tests whether a value is not
NULL
.
mysql>
SELECT 1 IS NOT NULL, 0 IS NOT NULL, NULL IS NOT NULL;
-> 1, 1, 0
•
expr BETWEEN min AND max
[877]
If
expr
is greater than or equal to
min
and
expr
is less than or equal to
max
,
BETWEEN
[877]
returns
1
, otherwise it returns
0
. This is equivalent to the expression
(min <= expr AND expr <=
max)
if all the arguments are of the same type. Otherwise type conversion takes place according to
the rules described in
Section 12.2, “Type Conversion in Expression Evaluation”
, but applied to all
the three arguments.
mysql>
SELECT 2 BETWEEN 1 AND 3, 2 BETWEEN 3 and 1;
-> 1, 0
mysql>
SELECT 1 BETWEEN 2 AND 3;
-> 0
mysql>
SELECT 'b' BETWEEN 'a' AND 'c';
-> 1
mysql>
SELECT 2 BETWEEN 2 AND '3';
-> 1
mysql>
SELECT 2 BETWEEN 2 AND 'x-3';
-> 0
Содержание 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 ...