この例は、リテラル リストを使用したIN/NOT INの動作を示しています。
テーブルの定義と内容は、次のものを想定します。
CREATE TABLE t (x INTEGER); INSERT t (1); INSERT t (2); INSERT t (3); INSERT t (4); INSERT t (5);
問合わせ | 結果 |
---|---|
SELECT * FROM t WHERE x IN (1,2) | 1, 2 |
SELECT * FROM t WHERE x IN ANY (1,2) | 1, 2 |
SELECT * FROM t WHERE NOT (x NOT IN (1,2)) | 1, 2 |
SELECT * FROM t WHERE x NOT IN (1,2) | 3, 4, 5 |
SELECT * FROM t WHERE x NOT IN ALL (1,2) | 3, 4, 5 |
SELECT * FROM t WHERE NOT (x IN (1, 2)) | 3, 4, 5 |
SELECT * FROM t WHERE NOT (x IN ANY (1,2)) | 3, 4, 5 |
SELECT * FROM t WHERE x IN (3 TO 5) | 3, 4, 5 |
SELECT * FROM t WHERE x NOT IN SOME (1, 2) | 1, 2, 3, 4, 5 |
SELECT * FROM t WHERE x IN (1, 2 TO 4, 5) | 1, 2, 3, 4, 5 |
SELECT * FROM t WHERE x IN ALL (1,2) | 行なし |
SELECT * FROM t WHERE NOT (x NOT IN SOME (1,2)) | 行なし |
SELECT * FROM t WHERE x NOT IN (1 TO 5) | 行なし |