Last active
July 20, 2021 00:52
-
-
Save yoku0825/3a974e44da42c6847fa9ce0917e17925 to your computer and use it in GitHub Desktop.
const OR NULLの結果
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- const OR NULLは | |
- constが真の時に短絡評価っぽい感じで真 | |
- constが偽の時に "偽とNULLの和集合" と評価されて不定(= NULL) | |
``` | |
mysql57 3> SELECT 1 /* means TRUE */ OR NULL, 0 /* meanse FALSE */ OR NULL; | |
+------------+------------+ | |
| 1 OR NULL | 0 OR NULL | | |
+------------+------------+ | |
| 1 | NULL | | |
+------------+------------+ | |
1 row in set (0.00 sec) | |
``` | |
- `真 IS NULL` は偽 | |
- `偽 IS NULL` は偽 | |
- `NULL IS NULL` は真 | |
よって↓になります | |
``` | |
mysql57 3> SELECT (1 IS NULL) OR NULL, (0 IS NULL) OR NULL, (NULL IS NULL) OR NULL; | |
+---------------------+---------------------+------------------------+ | |
| (1 IS NULL) OR NULL | (0 IS NULL) OR NULL | (NULL IS NULL) OR NULL | | |
+---------------------+---------------------+------------------------+ | |
| NULL | NULL | 1 | | |
+---------------------+---------------------+------------------------+ | |
1 row in set (0.00 sec) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment