回答編集履歴
5
タイポ修正
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
SELECT DISTINCT name FROM table t1
|
6
6
|
|
7
|
-
WHERE not exists(select 1 from table where name=t1.na
|
7
|
+
WHERE not exists(select 1 from table where name=t1.name and tag ='あああ')
|
8
8
|
|
9
9
|
```
|
10
10
|
|
@@ -18,6 +18,6 @@
|
|
18
18
|
|
19
19
|
) t1
|
20
20
|
|
21
|
-
WHERE not exists(select 1 from table where name=t1.na
|
21
|
+
WHERE not exists(select 1 from table where name=t1.name and tag ='あああ')
|
22
22
|
|
23
23
|
```
|
4
訂正
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
not existでも取得できます。
|
1
|
+
not existsでも取得できます。
|
2
2
|
|
3
3
|
```SQL
|
4
4
|
|
3
訂正
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
SELECT DISTINCT name FROM table t1
|
6
6
|
|
7
|
-
WHERE not exists(select 1 from table where name=t1.nane and tag =
|
7
|
+
WHERE not exists(select 1 from table where name=t1.nane and tag ='あああ')
|
8
8
|
|
9
9
|
```
|
10
10
|
|
@@ -18,6 +18,6 @@
|
|
18
18
|
|
19
19
|
) t1
|
20
20
|
|
21
|
-
WHERE not exists(select 1 from table where name=t1.nane and tag =
|
21
|
+
WHERE not exists(select 1 from table where name=t1.nane and tag ='あああ')
|
22
22
|
|
23
23
|
```
|
2
訂正
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
SELECT DISTINCT name FROM table t1
|
6
6
|
|
7
|
-
WHERE not exists(select 1 from table where name=t1.nane and tag
|
7
|
+
WHERE not exists(select 1 from table where name=t1.nane and tag =`あああ`)
|
8
8
|
|
9
9
|
```
|
10
10
|
|
@@ -18,6 +18,6 @@
|
|
18
18
|
|
19
19
|
) t1
|
20
20
|
|
21
|
-
WHERE not exists(select 1 from table where name=t1.nane and tag
|
21
|
+
WHERE not exists(select 1 from table where name=t1.nane and tag =`あああ`)
|
22
22
|
|
23
23
|
```
|
1
追記
test
CHANGED
@@ -7,3 +7,17 @@
|
|
7
7
|
WHERE not exists(select 1 from table where name=t1.nane and tag !="あああ")
|
8
8
|
|
9
9
|
```
|
10
|
+
|
11
|
+
以下の様にすると若干高速かもしれません。
|
12
|
+
|
13
|
+
```SQL
|
14
|
+
|
15
|
+
select * from (
|
16
|
+
|
17
|
+
SELECT DISTINCT name FROM table
|
18
|
+
|
19
|
+
) t1
|
20
|
+
|
21
|
+
WHERE not exists(select 1 from table where name=t1.nane and tag !="あああ")
|
22
|
+
|
23
|
+
```
|