Skip to content

Instantly share code, notes, and snippets.

@yoku0825
Last active July 20, 2021 00:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoku0825/3a974e44da42c6847fa9ce0917e17925 to your computer and use it in GitHub Desktop.
Save yoku0825/3a974e44da42c6847fa9ce0917e17925 to your computer and use it in GitHub Desktop.
const OR NULLの結果
- 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