回答編集履歴
4
SQL修正
test
CHANGED
@@ -40,11 +40,11 @@
|
|
40
40
|
|
41
41
|
SELECT user_id
|
42
42
|
|
43
|
-
FROM Table1
|
43
|
+
FROM Table1 AS a
|
44
44
|
|
45
45
|
WHERE item_id=1 AND
|
46
46
|
|
47
|
-
not exists (select user_id from table1 b where a.user_id = b.user_id AND item_id = 2);
|
47
|
+
not exists (select user_id from table1 AS b where a.user_id = b.user_id AND item_id = 2);
|
48
48
|
|
49
49
|
```
|
50
50
|
|
3
さらに回答追加
test
CHANGED
@@ -31,3 +31,21 @@
|
|
31
31
|
```
|
32
32
|
|
33
33
|
|
34
|
+
|
35
|
+
not exists を使うなら、
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
```SQL
|
40
|
+
|
41
|
+
SELECT user_id
|
42
|
+
|
43
|
+
FROM Table1
|
44
|
+
|
45
|
+
WHERE item_id=1 AND
|
46
|
+
|
47
|
+
not exists (select user_id from table1 b where a.user_id = b.user_id AND item_id = 2);
|
48
|
+
|
49
|
+
```
|
50
|
+
|
51
|
+
|
2
回答追加
test
CHANGED
@@ -13,3 +13,21 @@
|
|
13
13
|
WHERE a.item_id=1 AND b.user_id Is Null;
|
14
14
|
|
15
15
|
```
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
IN演算子を使ってもよさそう。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
```SQL
|
24
|
+
|
25
|
+
SELECT user_id
|
26
|
+
|
27
|
+
FROM Table1
|
28
|
+
|
29
|
+
WHERE item_id=1 AND user_id Not In (select user_id from table1 where item_id = 2);
|
30
|
+
|
31
|
+
```
|
32
|
+
|
33
|
+
|
1
SQLコード修正
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
```SQL
|
6
6
|
|
7
|
-
SELECT a.user_id
|
7
|
+
SELECT a.user_id
|
8
8
|
|
9
9
|
FROM Table1 AS a LEFT JOIN (select user_id From Table1 where item_id = 2) AS b
|
10
10
|
|