この例は、ANY/ALL/SOMEの動作を示したものです。
テーブルの定義と内容は、次のものを想定します。
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 ANY (1,2) | 1, 2 |
SELECT * FROM t WHERE x = SOME (1,2) | 1, 2 |
SELECT * FROM t WHERE x NOT IN ALL (1,2) | 3, 4, 5 |
SELECT * FROM t WHERE NOT (x IN ANY (1,2)) | 3, 4, 5 |
SELECT * FROM t WHERE NOT (x = SOME (1,2)) | 3, 4, 5 |
SELECT * FROM t WHERE x NOT IN SOME (1, 2) | 1, 2, 3, 4, 5 |
SELECT * FROM t WHERE x NOT = ANY (1, 2) | 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 = ALL (1,2) | 行なし |
SELECT * FROM t WHERE NOT (x NOT = ANY (1,2)) | 行なし |