質問編集履歴
4
追記2
test
CHANGED
File without changes
|
test
CHANGED
@@ -170,6 +170,6 @@
|
|
170
170
|
|
171
171
|
)cc
|
172
172
|
|
173
|
-
WHERE cc.word_id_1 NOT
|
173
|
+
WHERE cc.word_id_1 NOT IN(SELECT word_id FROM word)
|
174
174
|
|
175
175
|
```
|
3
追記2
test
CHANGED
File without changes
|
test
CHANGED
@@ -143,3 +143,33 @@
|
|
143
143
|
WHERE bv.word_id_1 IS NULL
|
144
144
|
|
145
145
|
```
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
追記2
|
154
|
+
|
155
|
+
指摘していただき、where NOT EXISTS( を 変更しましたが、結果はやはり0レコードでした(;_;)
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
```MySQL
|
160
|
+
|
161
|
+
SELECT cc.word_id_1
|
162
|
+
|
163
|
+
FROM (
|
164
|
+
|
165
|
+
(SELECT word_id_1 FROM video )
|
166
|
+
|
167
|
+
UNION
|
168
|
+
|
169
|
+
(SELECT word_id_2 FROM video )
|
170
|
+
|
171
|
+
)cc
|
172
|
+
|
173
|
+
WHERE cc.word_id_1 NOT EXISTS(SELECT word_id FROM word where cc.word_id_1=word_id)
|
174
|
+
|
175
|
+
```
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -117,3 +117,29 @@
|
|
117
117
|
```
|
118
118
|
|
119
119
|
selectしている場所を見るとそれぞれ結果は出ます。
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
追記
|
128
|
+
|
129
|
+
[https://qiita.com/Hiraku/items/71873bf31e503eb1b4e1](https://qiita.com/Hiraku/items/71873bf31e503eb1b4e1)
|
130
|
+
|
131
|
+
参考して下記のようにLEFT JOINにしても、同じくエラーはなく、結果は何も出ませんでした(T . T)
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
```MySQL
|
136
|
+
|
137
|
+
SELECT bv.word_id_1
|
138
|
+
|
139
|
+
FROM video bv
|
140
|
+
|
141
|
+
LEFT JOIN word dw ON dw.word_id = bv.word_id_1
|
142
|
+
|
143
|
+
WHERE bv.word_id_1 IS NULL
|
144
|
+
|
145
|
+
```
|
1
表などを追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,48 +16,104 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
+
|
20
|
+
|
21
|
+
tabel: video
|
22
|
+
|
23
|
+
|word_id_1|word_id_2|
|
24
|
+
|
25
|
+
|:--:|:--:|
|
26
|
+
|
27
|
+
|1|2|
|
28
|
+
|
29
|
+
|3|4|
|
30
|
+
|
31
|
+
|5|6|
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
tabel: word
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|word_id||
|
40
|
+
|
41
|
+
|:--:|--|
|
42
|
+
|
43
|
+
|1|
|
44
|
+
|
45
|
+
|2|
|
46
|
+
|
47
|
+
|3|
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
**完成目標**
|
52
|
+
|
53
|
+
|word_id||
|
54
|
+
|
55
|
+
|:--:|--|
|
56
|
+
|
57
|
+
|1|
|
58
|
+
|
59
|
+
|2|
|
60
|
+
|
61
|
+
|3|
|
62
|
+
|
63
|
+
|4|
|
64
|
+
|
65
|
+
|5|
|
66
|
+
|
67
|
+
|6|
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
19
|
-
```
|
73
|
+
```MySQL
|
20
74
|
|
21
75
|
INSERT INTO word (word_id)
|
22
76
|
|
23
|
-
SELECT
|
77
|
+
SELECT cc.word_id_1
|
24
78
|
|
25
79
|
FROM (
|
26
80
|
|
27
|
-
(SELECT word_id_1 FROM
|
81
|
+
(SELECT word_id_1 FROM video )
|
28
82
|
|
29
83
|
UNION
|
30
84
|
|
31
|
-
(SELECT word_id_2 FROM
|
85
|
+
(SELECT word_id_2 FROM video )
|
32
86
|
|
33
|
-
)
|
87
|
+
) cc
|
34
88
|
|
35
|
-
WHERE NOT EXISTS(SELECT w
|
89
|
+
WHERE NOT EXISTS(SELECT word_id FROM word)
|
36
90
|
|
37
91
|
```
|
38
92
|
|
39
93
|
|
40
94
|
|
41
|
-
イメージ的には word_id_1 - word_id で未登録のものだけを登録したいのですが、SELECTの結果が何もでてきません。
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
SELECT ww.word_id FROM word ww
|
46
|
-
|
47
|
-
と
|
48
|
-
|
49
|
-
(SELECT word_id_1 FROM buzz_video where word_id_1 <>"")
|
50
|
-
|
51
|
-
UNION
|
52
|
-
|
53
|
-
(SELECT word_id_2 FROM buzz_video where word_id_2 <>"")
|
54
95
|
|
55
96
|
|
56
97
|
|
57
98
|
|
99
|
+
実行結果ではエラーは出ませんが、SELECTの結果も何もでてきません。
|
58
100
|
|
59
|
-
は出てくるのでが差が出なくて困っています。
|
60
101
|
|
61
|
-
EXCEPT
|
62
102
|
|
63
|
-
|
103
|
+
```MySQL
|
104
|
+
|
105
|
+
(SELECT word_id_1 FROM video )
|
106
|
+
|
107
|
+
UNION
|
108
|
+
|
109
|
+
(SELECT word_id_2 FROM video )
|
110
|
+
|
111
|
+
```
|
112
|
+
|
113
|
+
```MySQL
|
114
|
+
|
115
|
+
SELECT word_id FROM word
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
selectしている場所を見るとそれぞれ結果は出ます。
|