質問編集履歴
2
結果件数を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -205,3 +205,25 @@
|
|
205
205
|
)
|
206
206
|
|
207
207
|
```
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
追記
|
212
|
+
|
213
|
+
---
|
214
|
+
|
215
|
+
table_aの件数は800件、table_bは810件
|
216
|
+
|
217
|
+
table_aとtable_bが一致している数790件
|
218
|
+
|
219
|
+
1つ目のSQLの実行結果は800件でNULLが入る件数が400件
|
220
|
+
|
221
|
+
1つ目のSQLのleft joinをjoinに変更すると790件になります
|
222
|
+
|
223
|
+
2つ目のSQLを実行すると10件になります。
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
left joinの結果だけがおかしいみたいです。
|
228
|
+
|
229
|
+
謎です。。
|
1
SQLを追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -153,3 +153,55 @@
|
|
153
153
|
|
154
154
|
|
155
155
|
よろしくお願いします。
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
---
|
162
|
+
|
163
|
+
not exists句を使ったSQLです、これはうまくいきました
|
164
|
+
|
165
|
+
```SQL
|
166
|
+
|
167
|
+
select
|
168
|
+
|
169
|
+
a.item_code,
|
170
|
+
|
171
|
+
a.color,
|
172
|
+
|
173
|
+
a.size
|
174
|
+
|
175
|
+
from table_a as a
|
176
|
+
|
177
|
+
where not exists ( select * from
|
178
|
+
|
179
|
+
(select
|
180
|
+
|
181
|
+
b.id
|
182
|
+
|
183
|
+
i.item_code,
|
184
|
+
|
185
|
+
c.color_code,
|
186
|
+
|
187
|
+
s.size_code
|
188
|
+
|
189
|
+
from table_b as b
|
190
|
+
|
191
|
+
join item as i on b.item_id = i.id
|
192
|
+
|
193
|
+
join color as c on b.color_id = c.id
|
194
|
+
|
195
|
+
join size as s on b.size_id = s.id
|
196
|
+
|
197
|
+
) as b2
|
198
|
+
|
199
|
+
where a.item_code = b2.item_code
|
200
|
+
|
201
|
+
and a.color = b2.color_code
|
202
|
+
|
203
|
+
and a.size = b2.size_code
|
204
|
+
|
205
|
+
)
|
206
|
+
|
207
|
+
```
|