MySQL Tutorial/Comparison Functions Operators/BETWEEN AND
Содержание
COALESCE(value,...) returns the first non-NULL value in the list, or NULL if there are no non-NULL values
mysql>
mysql> SELECT COALESCE(NULL,1);
+------------------+
| COALESCE(NULL,1) |
+------------------+
| 1 |
+------------------+
1 row in set (0.00 sec)
mysql>
mysql>
expr BETWEEN min AND max
expr NOT BETWEEN min AND max is the same as NOT (expr BETWEEN min AND max).
If expr is greater than or equal to min and expr is less than or equal to max, BETWEEN returns 1.
Otherwise it returns 0.
This is equivalent to the expression (min <= expr AND expr <= max).
mysql>
mysql> SELECT 1 BETWEEN 2 AND 3;
+-------------------+
| 1 BETWEEN 2 AND 3 |
+-------------------+
| 0 |
+-------------------+
1 row in set (0.00 sec)
mysql>
SELECT 2 BETWEEN 2 AND "3";
mysql>
mysql> SELECT 2 BETWEEN 2 AND "3";
+---------------------+
| 2 BETWEEN 2 AND "3" |
+---------------------+
| 1 |
+---------------------+
1 row in set (0.00 sec)
mysql>
SELECT 2 BETWEEN 2 AND "x-3";
mysql>
mysql> SELECT 2 BETWEEN 2 AND "x-3";
+-----------------------+
| 2 BETWEEN 2 AND "x-3" |
+-----------------------+
| 0 |
+-----------------------+
1 row in set, 1 warning (0.01 sec)
mysql>
SELECT "b" BETWEEN "a" AND "c";
mysql>
mysql> SELECT "b" BETWEEN "a" AND "c";
+-------------------------+
| "b" BETWEEN "a" AND "c" |
+-------------------------+
| 1 |
+-------------------------+
1 row in set (0.00 sec)
mysql>