1
by brian
clean slate |
1 |
--disable_warnings
|
2 |
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; |
|
3 |
--enable_warnings
|
|
4 |
||
5 |
CREATE TABLE t0 (a int, b int, c int); |
|
6 |
CREATE TABLE t1 (a int, b int, c int); |
|
7 |
CREATE TABLE t2 (a int, b int, c int); |
|
8 |
CREATE TABLE t3 (a int, b int, c int); |
|
9 |
CREATE TABLE t4 (a int, b int, c int); |
|
10 |
CREATE TABLE t5 (a int, b int, c int); |
|
11 |
CREATE TABLE t6 (a int, b int, c int); |
|
12 |
CREATE TABLE t7 (a int, b int, c int); |
|
13 |
CREATE TABLE t8 (a int, b int, c int); |
|
14 |
CREATE TABLE t9 (a int, b int, c int); |
|
15 |
||
16 |
INSERT INTO t0 VALUES (1,1,0), (1,2,0), (2,2,0); |
|
17 |
INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0); |
|
18 |
INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0); |
|
19 |
INSERT INTO t3 VALUES (1,2,0), (2,2,0); |
|
20 |
INSERT INTO t4 VALUES (3,2,0), (4,2,0); |
|
21 |
INSERT INTO t5 VALUES (3,1,0), (2,2,0), (3,3,0); |
|
22 |
INSERT INTO t6 VALUES (3,2,0), (6,2,0), (6,1,0); |
|
23 |
INSERT INTO t7 VALUES (1,1,0), (2,2,0); |
|
24 |
INSERT INTO t8 VALUES (0,2,0), (1,2,0); |
|
25 |
INSERT INTO t9 VALUES (1,1,0), (1,2,0), (3,3,0); |
|
26 |
||
27 |
||
28 |
SELECT t2.a,t2.b |
|
29 |
FROM t2; |
|
30 |
||
31 |
SELECT t3.a,t3.b |
|
32 |
FROM t3; |
|
33 |
||
34 |
SELECT t4.a,t4.b |
|
35 |
FROM t4; |
|
36 |
||
37 |
SELECT t3.a,t3.b,t4.a,t4.b |
|
38 |
FROM t3,t4; |
|
39 |
||
40 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
41 |
FROM t2 |
|
42 |
LEFT JOIN |
|
43 |
(t3, t4) |
|
44 |
ON t2.b=t4.b; |
|
45 |
||
46 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
47 |
FROM t2 |
|
48 |
LEFT JOIN |
|
49 |
(t3, t4) |
|
50 |
ON t3.a=1 AND t2.b=t4.b; |
|
51 |
||
52 |
EXPLAIN EXTENDED |
|
53 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
54 |
FROM t2 |
|
55 |
LEFT JOIN |
|
56 |
(t3, t4) |
|
57 |
ON t2.b=t4.b |
|
58 |
WHERE t3.a=1 OR t3.c IS NULL; |
|
59 |
||
60 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
61 |
FROM t2 |
|
62 |
LEFT JOIN |
|
63 |
(t3, t4) |
|
64 |
ON t2.b=t4.b |
|
65 |
WHERE t3.a=1 OR t3.c IS NULL; |
|
66 |
||
67 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
68 |
FROM t2 |
|
69 |
LEFT JOIN |
|
70 |
(t3, t4) |
|
71 |
ON t2.b=t4.b |
|
72 |
WHERE t3.a>1 OR t3.c IS NULL; |
|
73 |
||
74 |
SELECT t5.a,t5.b |
|
75 |
FROM t5; |
|
76 |
||
77 |
SELECT t3.a,t3.b,t4.a,t4.b,t5.a,t5.b |
|
78 |
FROM t3,t4,t5; |
|
79 |
||
80 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b |
|
81 |
FROM t2 |
|
82 |
LEFT JOIN |
|
83 |
(t3, t4, t5) |
|
84 |
ON t2.b=t4.b; |
|
85 |
||
86 |
EXPLAIN EXTENDED |
|
87 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b |
|
88 |
FROM t2 |
|
89 |
LEFT JOIN |
|
90 |
(t3, t4, t5) |
|
91 |
ON t2.b=t4.b |
|
92 |
WHERE t3.a>1 OR t3.c IS NULL; |
|
93 |
||
94 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b |
|
95 |
FROM t2 |
|
96 |
LEFT JOIN |
|
97 |
(t3, t4, t5) |
|
98 |
ON t2.b=t4.b |
|
99 |
WHERE t3.a>1 OR t3.c IS NULL; |
|
100 |
||
101 |
EXPLAIN EXTENDED |
|
102 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b |
|
103 |
FROM t2 |
|
104 |
LEFT JOIN |
|
105 |
(t3, t4, t5) |
|
106 |
ON t2.b=t4.b |
|
107 |
WHERE (t3.a>1 OR t3.c IS NULL) AND |
|
108 |
(t5.a<3 OR t5.c IS NULL); |
|
109 |
||
110 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b |
|
111 |
FROM t2 |
|
112 |
LEFT JOIN |
|
113 |
(t3, t4, t5) |
|
114 |
ON t2.b=t4.b |
|
115 |
WHERE (t3.a>1 OR t3.c IS NULL) AND |
|
116 |
(t5.a<3 OR t5.c IS NULL); |
|
117 |
||
118 |
SELECT t6.a,t6.b |
|
119 |
FROM t6; |
|
120 |
||
121 |
SELECT t7.a,t7.b |
|
122 |
FROM t7; |
|
123 |
||
124 |
SELECT t6.a,t6.b,t7.a,t7.b |
|
125 |
FROM t6,t7; |
|
126 |
||
127 |
SELECT t8.a,t8.b |
|
128 |
FROM t8; |
|
129 |
||
130 |
EXPLAIN EXTENDED |
|
131 |
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b |
|
132 |
FROM (t6, t7) |
|
133 |
LEFT JOIN |
|
134 |
t8
|
|
135 |
ON t7.b=t8.b AND t6.b < 10; |
|
136 |
||
137 |
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b |
|
138 |
FROM (t6, t7) |
|
139 |
LEFT JOIN |
|
140 |
t8
|
|
141 |
ON t7.b=t8.b AND t6.b < 10; |
|
142 |
||
143 |
SELECT t5.a,t5.b |
|
144 |
FROM t5; |
|
145 |
||
146 |
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b |
|
147 |
FROM t5 |
|
148 |
LEFT JOIN |
|
149 |
(
|
|
150 |
(t6, t7) |
|
151 |
LEFT JOIN |
|
152 |
t8
|
|
153 |
ON t7.b=t8.b AND t6.b < 10 |
|
154 |
)
|
|
155 |
ON t6.b >= 2 AND t5.b=t7.b; |
|
156 |
||
157 |
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b |
|
158 |
FROM t5 |
|
159 |
LEFT JOIN |
|
160 |
(
|
|
161 |
(t6, t7) |
|
162 |
LEFT JOIN |
|
163 |
t8
|
|
164 |
ON t7.b=t8.b AND t6.b < 10 |
|
165 |
)
|
|
166 |
ON t6.b >= 2 AND t5.b=t7.b AND |
|
167 |
(t8.a < 1 OR t8.c IS NULL); |
|
168 |
||
169 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
170 |
FROM t2 |
|
171 |
LEFT JOIN |
|
172 |
(t3, t4) |
|
173 |
ON t3.a=1 AND t2.b=t4.b; |
|
174 |
||
175 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
176 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b |
|
177 |
FROM t2 |
|
178 |
LEFT JOIN |
|
179 |
(t3, t4) |
|
180 |
ON t3.a=1 AND t2.b=t4.b, |
|
181 |
t5
|
|
182 |
LEFT JOIN |
|
183 |
(
|
|
184 |
(t6, t7) |
|
185 |
LEFT JOIN |
|
186 |
t8
|
|
187 |
ON t7.b=t8.b AND t6.b < 10 |
|
188 |
)
|
|
189 |
ON t6.b >= 2 AND t5.b=t7.b; |
|
190 |
||
191 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
192 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b |
|
193 |
FROM t2 |
|
194 |
LEFT JOIN |
|
195 |
(t3, t4) |
|
196 |
ON t3.a=1 AND t2.b=t4.b, |
|
197 |
t5
|
|
198 |
LEFT JOIN |
|
199 |
(
|
|
200 |
(t6, t7) |
|
201 |
LEFT JOIN |
|
202 |
t8
|
|
203 |
ON t7.b=t8.b AND t6.b < 10 |
|
204 |
)
|
|
205 |
ON t6.b >= 2 AND t5.b=t7.b |
|
206 |
WHERE t2.a > 3 AND |
|
207 |
(t6.a < 6 OR t6.c IS NULL); |
|
208 |
||
209 |
SELECT t1.a,t1.b |
|
210 |
FROM t1; |
|
211 |
||
212 |
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
213 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b |
|
214 |
FROM t1 |
|
215 |
LEFT JOIN |
|
216 |
(
|
|
217 |
t2
|
|
218 |
LEFT JOIN |
|
219 |
(t3, t4) |
|
220 |
ON t3.a=1 AND t2.b=t4.b, |
|
221 |
t5
|
|
222 |
LEFT JOIN |
|
223 |
(
|
|
224 |
(t6, t7) |
|
225 |
LEFT JOIN |
|
226 |
t8
|
|
227 |
ON t7.b=t8.b AND t6.b < 10 |
|
228 |
)
|
|
229 |
ON t6.b >= 2 AND t5.b=t7.b |
|
230 |
)
|
|
231 |
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND |
|
232 |
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND |
|
233 |
(t1.a != 2); |
|
234 |
||
235 |
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
236 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b |
|
237 |
FROM t1 |
|
238 |
LEFT JOIN |
|
239 |
(
|
|
240 |
t2
|
|
241 |
LEFT JOIN |
|
242 |
(t3, t4) |
|
243 |
ON t3.a=1 AND t2.b=t4.b, |
|
244 |
t5
|
|
245 |
LEFT JOIN |
|
246 |
(
|
|
247 |
(t6, t7) |
|
248 |
LEFT JOIN |
|
249 |
t8
|
|
250 |
ON t7.b=t8.b AND t6.b < 10 |
|
251 |
)
|
|
252 |
ON t6.b >= 2 AND t5.b=t7.b |
|
253 |
)
|
|
254 |
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND |
|
255 |
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND |
|
256 |
(t1.a != 2) |
|
257 |
WHERE (t2.a >= 4 OR t2.c IS NULL); |
|
258 |
||
259 |
SELECT t0.a,t0.b |
|
260 |
FROM t0; |
|
261 |
||
262 |
EXPLAIN EXTENDED |
|
263 |
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
264 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b |
|
265 |
FROM t0,t1 |
|
266 |
LEFT JOIN |
|
267 |
(
|
|
268 |
t2
|
|
269 |
LEFT JOIN |
|
270 |
(t3, t4) |
|
271 |
ON t3.a=1 AND t2.b=t4.b, |
|
272 |
t5
|
|
273 |
LEFT JOIN |
|
274 |
(
|
|
275 |
(t6, t7) |
|
276 |
LEFT JOIN |
|
277 |
t8
|
|
278 |
ON t7.b=t8.b AND t6.b < 10 |
|
279 |
)
|
|
280 |
ON t6.b >= 2 AND t5.b=t7.b |
|
281 |
)
|
|
282 |
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND |
|
283 |
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND |
|
284 |
(t1.a != 2) |
|
285 |
WHERE t0.a=1 AND |
|
286 |
t0.b=t1.b AND |
|
287 |
(t2.a >= 4 OR t2.c IS NULL); |
|
288 |
||
289 |
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
290 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b |
|
291 |
FROM t0,t1 |
|
292 |
LEFT JOIN |
|
293 |
(
|
|
294 |
t2
|
|
295 |
LEFT JOIN |
|
296 |
(t3, t4) |
|
297 |
ON t3.a=1 AND t2.b=t4.b, |
|
298 |
t5
|
|
299 |
LEFT JOIN |
|
300 |
(
|
|
301 |
(t6, t7) |
|
302 |
LEFT JOIN |
|
303 |
t8
|
|
304 |
ON t7.b=t8.b AND t6.b < 10 |
|
305 |
)
|
|
306 |
ON t6.b >= 2 AND t5.b=t7.b |
|
307 |
)
|
|
308 |
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND |
|
309 |
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND |
|
310 |
(t1.a != 2) |
|
311 |
WHERE t0.a=1 AND |
|
312 |
t0.b=t1.b AND |
|
313 |
(t2.a >= 4 OR t2.c IS NULL); |
|
314 |
||
315 |
EXPLAIN EXTENDED |
|
316 |
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
317 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b |
|
318 |
FROM t0,t1 |
|
319 |
LEFT JOIN |
|
320 |
(
|
|
321 |
t2
|
|
322 |
LEFT JOIN |
|
323 |
(t3, t4) |
|
324 |
ON t3.a=1 AND t2.b=t4.b, |
|
325 |
t5
|
|
326 |
LEFT JOIN |
|
327 |
(
|
|
328 |
(t6, t7) |
|
329 |
LEFT JOIN |
|
330 |
t8
|
|
331 |
ON t7.b=t8.b AND t6.b < 10 |
|
332 |
)
|
|
333 |
ON t6.b >= 2 AND t5.b=t7.b |
|
334 |
)
|
|
335 |
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND |
|
336 |
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND |
|
337 |
(t1.a != 2), |
|
338 |
t9
|
|
339 |
WHERE t0.a=1 AND |
|
340 |
t0.b=t1.b AND |
|
341 |
(t2.a >= 4 OR t2.c IS NULL) AND |
|
342 |
(t3.a < 5 OR t3.c IS NULL) AND |
|
343 |
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND |
|
344 |
(t5.a >=2 OR t5.c IS NULL) AND |
|
345 |
(t6.a >=4 OR t6.c IS NULL) AND |
|
346 |
(t7.a <= 2 OR t7.c IS NULL) AND |
|
347 |
(t8.a < 1 OR t8.c IS NULL) AND |
|
348 |
(t8.b=t9.b OR t8.c IS NULL) AND |
|
349 |
(t9.a=1); |
|
350 |
||
351 |
SELECT t9.a,t9.b |
|
352 |
FROM t9; |
|
353 |
||
354 |
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
355 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b |
|
356 |
FROM t0,t1 |
|
357 |
LEFT JOIN |
|
358 |
(
|
|
359 |
t2
|
|
360 |
LEFT JOIN |
|
361 |
(t3, t4) |
|
362 |
ON t3.a=1 AND t2.b=t4.b, |
|
363 |
t5
|
|
364 |
LEFT JOIN |
|
365 |
(
|
|
366 |
(t6, t7) |
|
367 |
LEFT JOIN |
|
368 |
t8
|
|
369 |
ON t7.b=t8.b AND t6.b < 10 |
|
370 |
)
|
|
371 |
ON t6.b >= 2 AND t5.b=t7.b |
|
372 |
)
|
|
373 |
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND |
|
374 |
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND |
|
375 |
(t1.a != 2), |
|
376 |
t9
|
|
377 |
WHERE t0.a=1 AND |
|
378 |
t0.b=t1.b AND |
|
379 |
(t2.a >= 4 OR t2.c IS NULL) AND |
|
380 |
(t3.a < 5 OR t3.c IS NULL) AND |
|
381 |
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND |
|
382 |
(t5.a >=2 OR t5.c IS NULL) AND |
|
383 |
(t6.a >=4 OR t6.c IS NULL) AND |
|
384 |
(t7.a <= 2 OR t7.c IS NULL) AND |
|
385 |
(t8.a < 1 OR t8.c IS NULL) AND |
|
386 |
(t8.b=t9.b OR t8.c IS NULL) AND |
|
387 |
(t9.a=1); |
|
388 |
||
389 |
SELECT t1.a,t1.b |
|
390 |
FROM t1; |
|
391 |
||
392 |
SELECT t2.a,t2.b |
|
393 |
FROM t2; |
|
394 |
||
395 |
SELECT t3.a,t3.b |
|
396 |
FROM t3; |
|
397 |
||
398 |
SELECT t2.a,t2.b,t3.a,t3.b |
|
399 |
FROM t2 |
|
400 |
LEFT JOIN |
|
401 |
t3
|
|
402 |
ON t2.b=t3.b; |
|
403 |
||
404 |
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b |
|
405 |
FROM t1, t2 |
|
406 |
LEFT JOIN |
|
407 |
t3
|
|
408 |
ON t2.b=t3.b |
|
409 |
WHERE t1.a <= 2; |
|
410 |
||
411 |
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b |
|
412 |
FROM t1, t3 |
|
413 |
RIGHT JOIN |
|
414 |
t2
|
|
415 |
ON t2.b=t3.b |
|
416 |
WHERE t1.a <= 2; |
|
417 |
||
418 |
SELECT t3.a,t3.b,t4.a,t4.b |
|
419 |
FROM t3,t4; |
|
420 |
||
421 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
422 |
FROM t2 |
|
423 |
LEFT JOIN |
|
424 |
(t3, t4) |
|
425 |
ON t3.a=1 AND t2.b=t4.b; |
|
426 |
||
427 |
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
428 |
FROM t1, t2 |
|
429 |
LEFT JOIN |
|
430 |
(t3, t4) |
|
431 |
ON t3.a=1 AND t2.b=t4.b |
|
432 |
WHERE t1.a <= 2; |
|
433 |
||
434 |
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
435 |
FROM t1, (t3, t4) |
|
436 |
RIGHT JOIN |
|
437 |
t2
|
|
438 |
ON t3.a=1 AND t2.b=t4.b |
|
439 |
WHERE t1.a <= 2; |
|
440 |
||
441 |
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
442 |
FROM t1, (t3, t4) |
|
443 |
RIGHT JOIN |
|
444 |
t2
|
|
445 |
ON t3.a=1 AND t2.b=t4.b |
|
446 |
WHERE t1.a <= 2; |
|
447 |
||
448 |
EXPLAIN EXTENDED |
|
449 |
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
450 |
FROM t1, (t3, t4) |
|
451 |
RIGHT JOIN |
|
452 |
t2
|
|
453 |
ON t3.a=1 AND t2.b=t4.b |
|
454 |
WHERE t1.a <= 2; |
|
455 |
||
456 |
CREATE INDEX idx_b ON t2(b); |
|
457 |
||
458 |
EXPLAIN EXTENDED |
|
459 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
460 |
FROM (t3,t4) |
|
461 |
LEFT JOIN |
|
462 |
(t1,t2) |
|
463 |
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; |
|
464 |
||
465 |
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b |
|
466 |
FROM (t3,t4) |
|
467 |
LEFT JOIN |
|
468 |
(t1,t2) |
|
469 |
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; |
|
470 |
||
471 |
EXPLAIN EXTENDED |
|
472 |
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
473 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b |
|
474 |
FROM t0,t1 |
|
475 |
LEFT JOIN |
|
476 |
(
|
|
477 |
t2
|
|
478 |
LEFT JOIN |
|
479 |
(t3, t4) |
|
480 |
ON t3.a=1 AND t2.b=t4.b, |
|
481 |
t5
|
|
482 |
LEFT JOIN |
|
483 |
(
|
|
484 |
(t6, t7) |
|
485 |
LEFT JOIN |
|
486 |
t8
|
|
487 |
ON t7.b=t8.b AND t6.b < 10 |
|
488 |
)
|
|
489 |
ON t6.b >= 2 AND t5.b=t7.b |
|
490 |
)
|
|
491 |
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND |
|
492 |
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND |
|
493 |
(t1.a != 2), |
|
494 |
t9
|
|
495 |
WHERE t0.a=1 AND |
|
496 |
t0.b=t1.b AND |
|
497 |
(t2.a >= 4 OR t2.c IS NULL) AND |
|
498 |
(t3.a < 5 OR t3.c IS NULL) AND |
|
499 |
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND |
|
500 |
(t5.a >=2 OR t5.c IS NULL) AND |
|
501 |
(t6.a >=4 OR t6.c IS NULL) AND |
|
502 |
(t7.a <= 2 OR t7.c IS NULL) AND |
|
503 |
(t8.a < 1 OR t8.c IS NULL) AND |
|
504 |
(t8.b=t9.b OR t8.c IS NULL) AND |
|
505 |
(t9.a=1); |
|
506 |
||
507 |
CREATE INDEX idx_b ON t4(b); |
|
508 |
CREATE INDEX idx_b ON t5(b); |
|
509 |
||
510 |
EXPLAIN EXTENDED |
|
511 |
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
512 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b |
|
513 |
FROM t0,t1 |
|
514 |
LEFT JOIN |
|
515 |
(
|
|
516 |
t2
|
|
517 |
LEFT JOIN |
|
518 |
(t3, t4) |
|
519 |
ON t3.a=1 AND t2.b=t4.b, |
|
520 |
t5
|
|
521 |
LEFT JOIN |
|
522 |
(
|
|
523 |
(t6, t7) |
|
524 |
LEFT JOIN |
|
525 |
t8
|
|
526 |
ON t7.b=t8.b AND t6.b < 10 |
|
527 |
)
|
|
528 |
ON t6.b >= 2 AND t5.b=t7.b |
|
529 |
)
|
|
530 |
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND |
|
531 |
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND |
|
532 |
(t1.a != 2), |
|
533 |
t9
|
|
534 |
WHERE t0.a=1 AND |
|
535 |
t0.b=t1.b AND |
|
536 |
(t2.a >= 4 OR t2.c IS NULL) AND |
|
537 |
(t3.a < 5 OR t3.c IS NULL) AND |
|
538 |
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND |
|
539 |
(t5.a >=2 OR t5.c IS NULL) AND |
|
540 |
(t6.a >=4 OR t6.c IS NULL) AND |
|
541 |
(t7.a <= 2 OR t7.c IS NULL) AND |
|
542 |
(t8.a < 1 OR t8.c IS NULL) AND |
|
543 |
(t8.b=t9.b OR t8.c IS NULL) AND |
|
544 |
(t9.a=1); |
|
545 |
||
546 |
CREATE INDEX idx_b ON t8(b); |
|
547 |
||
548 |
EXPLAIN EXTENDED |
|
549 |
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
550 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b |
|
551 |
FROM t0,t1 |
|
552 |
LEFT JOIN |
|
553 |
(
|
|
554 |
t2
|
|
555 |
LEFT JOIN |
|
556 |
(t3, t4) |
|
557 |
ON t3.a=1 AND t2.b=t4.b, |
|
558 |
t5
|
|
559 |
LEFT JOIN |
|
560 |
(
|
|
561 |
(t6, t7) |
|
562 |
LEFT JOIN |
|
563 |
t8
|
|
564 |
ON t7.b=t8.b AND t6.b < 10 |
|
565 |
)
|
|
566 |
ON t6.b >= 2 AND t5.b=t7.b |
|
567 |
)
|
|
568 |
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND |
|
569 |
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND |
|
570 |
(t1.a != 2), |
|
571 |
t9
|
|
572 |
WHERE t0.a=1 AND |
|
573 |
t0.b=t1.b AND |
|
574 |
(t2.a >= 4 OR t2.c IS NULL) AND |
|
575 |
(t3.a < 5 OR t3.c IS NULL) AND |
|
576 |
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND |
|
577 |
(t5.a >=2 OR t5.c IS NULL) AND |
|
578 |
(t6.a >=4 OR t6.c IS NULL) AND |
|
579 |
(t7.a <= 2 OR t7.c IS NULL) AND |
|
580 |
(t8.a < 1 OR t8.c IS NULL) AND |
|
581 |
(t8.b=t9.b OR t8.c IS NULL) AND |
|
582 |
(t9.a=1); |
|
583 |
||
584 |
CREATE INDEX idx_b ON t1(b); |
|
585 |
CREATE INDEX idx_a ON t0(a); |
|
586 |
||
587 |
EXPLAIN EXTENDED |
|
588 |
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
589 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b |
|
590 |
FROM t0,t1 |
|
591 |
LEFT JOIN |
|
592 |
(
|
|
593 |
t2
|
|
594 |
LEFT JOIN |
|
595 |
(t3, t4) |
|
596 |
ON t3.a=1 AND t2.b=t4.b, |
|
597 |
t5
|
|
598 |
LEFT JOIN |
|
599 |
(
|
|
600 |
(t6, t7) |
|
601 |
LEFT JOIN |
|
602 |
t8
|
|
603 |
ON t7.b=t8.b AND t6.b < 10 |
|
604 |
)
|
|
605 |
ON t6.b >= 2 AND t5.b=t7.b |
|
606 |
)
|
|
607 |
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND |
|
608 |
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND |
|
609 |
(t1.a != 2), |
|
610 |
t9
|
|
611 |
WHERE t0.a=1 AND |
|
612 |
t0.b=t1.b AND |
|
613 |
(t2.a >= 4 OR t2.c IS NULL) AND |
|
614 |
(t3.a < 5 OR t3.c IS NULL) AND |
|
615 |
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND |
|
616 |
(t5.a >=2 OR t5.c IS NULL) AND |
|
617 |
(t6.a >=4 OR t6.c IS NULL) AND |
|
618 |
(t7.a <= 2 OR t7.c IS NULL) AND |
|
619 |
(t8.a < 1 OR t8.c IS NULL) AND |
|
620 |
(t8.b=t9.b OR t8.c IS NULL) AND |
|
621 |
(t9.a=1); |
|
622 |
||
623 |
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, |
|
624 |
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b |
|
625 |
FROM t0,t1 |
|
626 |
LEFT JOIN |
|
627 |
(
|
|
628 |
t2
|
|
629 |
LEFT JOIN |
|
630 |
(t3, t4) |
|
631 |
ON t3.a=1 AND t2.b=t4.b, |
|
632 |
t5
|
|
633 |
LEFT JOIN |
|
634 |
(
|
|
635 |
(t6, t7) |
|
636 |
LEFT JOIN |
|
637 |
t8
|
|
638 |
ON t7.b=t8.b AND t6.b < 10 |
|
639 |
)
|
|
640 |
ON t6.b >= 2 AND t5.b=t7.b |
|
641 |
)
|
|
642 |
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND |
|
643 |
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND |
|
644 |
(t1.a != 2), |
|
645 |
t9
|
|
646 |
WHERE t0.a=1 AND |
|
647 |
t0.b=t1.b AND |
|
648 |
(t2.a >= 4 OR t2.c IS NULL) AND |
|
649 |
(t3.a < 5 OR t3.c IS NULL) AND |
|
650 |
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND |
|
651 |
(t5.a >=2 OR t5.c IS NULL) AND |
|
652 |
(t6.a >=4 OR t6.c IS NULL) AND |
|
653 |
(t7.a <= 2 OR t7.c IS NULL) AND |
|
654 |
(t8.a < 1 OR t8.c IS NULL) AND |
|
655 |
(t8.b=t9.b OR t8.c IS NULL) AND |
|
656 |
(t9.a=1); |
|
657 |
||
658 |
SELECT t2.a,t2.b |
|
659 |
FROM t2; |
|
660 |
||
661 |
SELECT t3.a,t3.b |
|
662 |
FROM t3; |
|
663 |
||
664 |
SELECT t2.a,t2.b,t3.a,t3.b |
|
665 |
FROM t2 LEFT JOIN t3 ON t2.b=t3.b |
|
666 |
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); |
|
667 |
||
668 |
SELECT t2.a,t2.b,t3.a,t3.b |
|
669 |
FROM t2 LEFT JOIN (t3) ON t2.b=t3.b |
|
670 |
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); |
|
671 |
||
672 |
ALTER TABLE t3 |
|
673 |
CHANGE COLUMN a a1 int, |
|
674 |
CHANGE COLUMN c c1 int; |
|
675 |
||
676 |
SELECT t2.a,t2.b,t3.a1,t3.b |
|
677 |
FROM t2 LEFT JOIN t3 ON t2.b=t3.b |
|
678 |
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); |
|
679 |
||
680 |
SELECT t2.a,t2.b,t3.a1,t3.b |
|
681 |
FROM t2 NATURAL LEFT JOIN t3 |
|
682 |
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); |
|
683 |
||
684 |
DROP TABLE t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; |
|
685 |
||
686 |
CREATE TABLE t1 (a int); |
|
687 |
CREATE TABLE t2 (a int); |
|
688 |
CREATE TABLE t3 (a int); |
|
689 |
||
690 |
INSERT INTO t1 VALUES (1); |
|
691 |
INSERT INTO t2 VALUES (2); |
|
692 |
INSERT INTO t3 VALUES (2); |
|
693 |
INSERT INTO t1 VALUES (2); |
|
694 |
||
695 |
#check proper syntax for nested outer joins |
|
696 |
||
697 |
SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.a=t3.a; |
|
698 |
||
699 |
#must be equivalent to: |
|
700 |
||
701 |
SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; |
|
702 |
||
703 |
#check that everything is al right when all tables contain not more than 1 row |
|
704 |
#(bug #4922) |
|
705 |
||
706 |
DELETE FROM t1 WHERE a=2; |
|
707 |
SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; |
|
708 |
DELETE FROM t2; |
|
709 |
SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; |
|
710 |
||
711 |
DROP TABLE t1,t2,t3; |
|
712 |
||
713 |
#on expression for a nested outer join does not depend on the outer table |
|
714 |
#bug #4976 |
|
715 |
||
716 |
CREATE TABLE t1(a int, key (a)); |
|
717 |
CREATE TABLE t2(b int, key (b)); |
|
718 |
CREATE TABLE t3(c int, key (c)); |
|
719 |
||
720 |
INSERT INTO t1 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), |
|
721 |
(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); |
|
722 |
||
723 |
INSERT INTO t2 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), |
|
724 |
(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); |
|
725 |
||
726 |
INSERT INTO t3 VALUES (0), (1), (2), (3), (4), (5); |
|
727 |
||
728 |
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c; |
|
729 |
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; |
|
730 |
SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; |
|
731 |
||
732 |
DELETE FROM t3; |
|
733 |
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; |
|
734 |
SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; |
|
735 |
||
736 |
DROP TABLE t1,t2,t3; |
|
737 |
||
738 |
#
|
|
739 |
# Test for bug #11284: empty table in a nested left join |
|
740 |
#
|
|
741 |
||
742 |
CREATE TABLE t1 (c11 int); |
|
743 |
CREATE TABLE t2 (c21 int); |
|
744 |
CREATE TABLE t3 (c31 int); |
|
745 |
||
746 |
INSERT INTO t1 VALUES (4), (5); |
|
747 |
||
748 |
SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; |
|
749 |
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; |
|
750 |
||
751 |
SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; |
|
752 |
EXPLAIN SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; |
|
753 |
||
754 |
DROP TABLE t1,t2,t3; |
|
755 |
||
756 |
# BUG#16393 |
|
757 |
create table t1 (a int); |
|
758 |
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); |
|
759 |
create table t2 (a int, filler char(100), key(a)); |
|
760 |
insert into t2 select A.a + 10*B.a, '' from t1 A, t1 B; |
|
761 |
create table t3 like t2; |
|
762 |
insert into t3 select * from t2; |
|
763 |
||
764 |
explain select * from t1 left join |
|
765 |
(t2 left join t3 on (t2.a = t3.a)) |
|
766 |
on (t1.a = t2.a); |
|
767 |
drop table t1, t2, t3; |
|
768 |
||
769 |
#
|
|
770 |
# Test for bug #24345: crash with nested left outer join when outer table is substituted |
|
771 |
# for a row that happens to have a null value for the join attribute. |
|
772 |
#
|
|
773 |
||
774 |
CREATE TABLE t1 ( |
|
775 |
id int NOT NULL PRIMARY KEY, |
|
776 |
ct int DEFAULT NULL, |
|
777 |
pc int DEFAULT NULL, |
|
778 |
INDEX idx_ct (ct), |
|
779 |
INDEX idx_pc (pc) |
|
780 |
);
|
|
781 |
INSERT INTO t1 VALUES |
|
782 |
(1,NULL,NULL),(2,NULL,NULL),(3,NULL,NULL),(4,NULL,NULL),(5,NULL,NULL); |
|
783 |
||
784 |
CREATE TABLE t2 ( |
|
785 |
id int NOT NULL PRIMARY KEY, |
|
786 |
sr int NOT NULL, |
|
787 |
nm varchar(255) NOT NULL, |
|
788 |
INDEX idx_sr (sr) |
|
789 |
);
|
|
790 |
INSERT INTO t2 VALUES |
|
791 |
(2441905,4308,'LesAbymes'),(2441906,4308,'Anse-Bertrand'); |
|
792 |
||
793 |
CREATE TABLE t3 ( |
|
794 |
id int NOT NULL PRIMARY KEY, |
|
795 |
ct int NOT NULL, |
|
796 |
ln int NOT NULL, |
|
797 |
INDEX idx_ct (ct), |
|
798 |
INDEX idx_ln (ln) |
|
799 |
);
|
|
800 |
||
801 |
CREATE TABLE t4 ( |
|
802 |
id int NOT NULL PRIMARY KEY, |
|
803 |
nm varchar(255) NOT NULL |
|
804 |
);
|
|
805 |
||
806 |
INSERT INTO t4 VALUES (4308,'Guadeloupe'),(4309,'Martinique'); |
|
807 |
||
808 |
SELECT t1.* |
|
809 |
FROM t1 LEFT JOIN |
|
810 |
(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id |
|
811 |
WHERE t1.id='5'; |
|
812 |
||
813 |
SELECT t1.*, t4.nm |
|
814 |
FROM t1 LEFT JOIN |
|
815 |
(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id |
|
816 |
LEFT JOIN t4 ON t2.sr=t4.id |
|
817 |
WHERE t1.id='5'; |
|
818 |
||
819 |
DROP TABLE t1,t2,t3,t4; |
|
820 |
||
821 |
#
|
|
822 |
# BUG#25575: ERROR 1052 (Column in from clause is ambiguous) with sub-join |
|
823 |
#
|
|
824 |
CREATE TABLE t1 (a INT, b INT); |
|
825 |
CREATE TABLE t2 (a INT); |
|
826 |
CREATE TABLE t3 (a INT, c INT); |
|
827 |
CREATE TABLE t4 (a INT, c INT); |
|
828 |
CREATE TABLE t5 (a INT, c INT); |
|
829 |
||
830 |
SELECT b FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) |
|
831 |
LEFT JOIN t5 USING (a)) USING (a); |
|
832 |
||
833 |
--error ER_NON_UNIQ_ERROR
|
|
834 |
SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) |
|
835 |
LEFT JOIN t5 USING (a)) USING (a); |
|
836 |
||
837 |
SELECT b FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) |
|
838 |
JOIN t5 USING (a)) USING (a); |
|
839 |
||
840 |
--error ER_NON_UNIQ_ERROR
|
|
841 |
SELECT c FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) |
|
842 |
JOIN t5 USING (a)) USING (a); |
|
843 |
||
844 |
DROP TABLE t1,t2,t3,t4,t5; |
|
845 |
CREATE TABLE t1 (a INT, b INT); |
|
846 |
CREATE TABLE t2 (a INT, b INT); |
|
847 |
CREATE TABLE t3 (a INT, b INT); |
|
848 |
||
849 |
INSERT INTO t1 VALUES (1,1); |
|
850 |
INSERT INTO t2 VALUES (1,1); |
|
851 |
INSERT INTO t3 VALUES (1,1); |
|
852 |
||
853 |
--error ER_NON_UNIQ_ERROR
|
|
854 |
SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a); |
|
855 |
||
856 |
DROP TABLE t1,t2,t3; |
|
857 |
||
858 |
#
|
|
859 |
# BUG#29604: inner nest of left join interleaves with outer tables |
|
860 |
#
|
|
861 |
||
862 |
CREATE TABLE t1 ( |
|
863 |
carrier char(2) default NULL, |
|
864 |
id int NOT NULL auto_increment PRIMARY KEY |
|
865 |
);
|
|
866 |
INSERT INTO t1 VALUES |
|
867 |
('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874), |
|
868 |
('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484), |
|
869 |
('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594), |
|
870 |
('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424), |
|
871 |
('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464), |
|
872 |
('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864), |
|
873 |
('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014), |
|
874 |
('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534), |
|
875 |
('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974); |
|
876 |
||
877 |
CREATE TABLE t2 ( |
|
878 |
scan_date date default NULL, |
|
879 |
package_id int default NULL, |
|
880 |
INDEX scan_date(scan_date), |
|
881 |
INDEX package_id(package_id) |
|
882 |
);
|
|
883 |
INSERT INTO t2 VALUES |
|
884 |
('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124), |
|
885 |
('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644), |
|
886 |
('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774), |
|
887 |
('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004), |
|
888 |
('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884), |
|
889 |
('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144), |
|
890 |
('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414), |
|
891 |
('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614), |
|
892 |
('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614), |
|
893 |
('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094), |
|
894 |
('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804), |
|
895 |
('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344), |
|
896 |
('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594), |
|
897 |
('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914), |
|
898 |
('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904); |
|
899 |
||
900 |
CREATE TABLE t3 ( |
|
901 |
package_id int default NULL, |
|
902 |
INDEX package_id(package_id) |
|
903 |
);
|
|
904 |
INSERT INTO t3 VALUES |
|
905 |
(231058294),(231058324),(231058354),(231058384),(231058414),(231058444), |
|
906 |
(231058474),(231058504),(231058534),(231058564),(231058594),(231058624), |
|
907 |
(231058684),(231058744),(231058804),(231058864),(231058924),(231058954), |
|
908 |
(231059014),(231059074),(231059104),(231059134),(231059164),(231059194), |
|
909 |
(231059224),(231059254),(231059284),(231059314),(231059344),(231059374), |
|
910 |
(231059404),(231059434),(231059464),(231059494),(231059524),(231059554), |
|
911 |
(231059584),(231059614),(231059644),(231059674),(231059704),(231059734), |
|
912 |
(231059764),(231059794),(231059824),(231059854),(231059884),(231059914), |
|
913 |
(231059944),(231059974),(231060004),(231060034),(231060064),(231060094), |
|
914 |
(231060124),(231060154),(231060184),(231060214),(231060244),(231060274), |
|
915 |
(231060304),(231060334),(231060364),(231060394),(231060424),(231060454), |
|
916 |
(231060484),(231060514),(231060544),(231060574),(231060604),(231060634), |
|
917 |
(231060664),(231060694),(231060724),(231060754),(231060784),(231060814), |
|
918 |
(231060844),(231060874),(231060904),(231060934),(231060964),(231060994), |
|
919 |
(231061024),(231061054),(231061084),(231061144),(231061174),(231061204), |
|
920 |
(231061234),(231061294),(231061354),(231061384),(231061414),(231061474), |
|
921 |
(231061564),(231061594),(231061624),(231061684),(231061714),(231061774), |
|
922 |
(231061804),(231061894),(231061984),(231062074),(231062134),(231062224), |
|
923 |
(231062254),(231062314),(231062374),(231062434),(231062494),(231062554), |
|
924 |
(231062584),(231062614),(231062644),(231062704),(231062734),(231062794), |
|
925 |
(231062854),(231062884),(231062944),(231063004),(231063034),(231063064), |
|
926 |
(231063124),(231063154),(231063184),(231063214),(231063274),(231063334), |
|
927 |
(231063394),(231063424),(231063454),(231063514),(231063574),(231063664); |
|
928 |
||
929 |
CREATE TABLE t4 ( |
|
930 |
carrier char(2) NOT NULL default '' PRIMARY KEY, |
|
931 |
id int(11) default NULL, |
|
932 |
INDEX id(id) |
|
933 |
);
|
|
934 |
INSERT INTO t4 VALUES |
|
935 |
('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510); |
|
936 |
||
937 |
CREATE TABLE t5 ( |
|
938 |
carrier_id int default NULL, |
|
939 |
INDEX carrier_id(carrier_id) |
|
940 |
);
|
|
941 |
INSERT INTO t5 VALUES |
|
942 |
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), |
|
943 |
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), |
|
944 |
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), |
|
945 |
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), |
|
946 |
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), |
|
947 |
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456), |
|
948 |
(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456), |
|
949 |
(456),(486),(1081),(1111),(1111),(1111),(1111),(1510); |
|
950 |
||
951 |
SELECT COUNT(*) |
|
952 |
FROM((t2 JOIN t1 ON t2.package_id = t1.id) |
|
953 |
JOIN t3 ON t3.package_id = t1.id); |
|
954 |
||
955 |
EXPLAIN
|
|
956 |
SELECT COUNT(*) |
|
957 |
FROM ((t2 JOIN t1 ON t2.package_id = t1.id) |
|
958 |
JOIN t3 ON t3.package_id = t1.id) |
|
959 |
LEFT JOIN |
|
960 |
(t5 JOIN t4 ON t5.carrier_id = t4.id) |
|
961 |
ON t4.carrier = t1.carrier; |
|
962 |
SELECT COUNT(*) |
|
963 |
FROM ((t2 JOIN t1 ON t2.package_id = t1.id) |
|
964 |
JOIN t3 ON t3.package_id = t1.id) |
|
965 |
LEFT JOIN |
|
966 |
(t5 JOIN t4 ON t5.carrier_id = t4.id) |
|
967 |
ON t4.carrier = t1.carrier; |
|
968 |
||
969 |
DROP TABLE t1,t2,t3,t4,t5; |
|
970 |
||
971 |
--echo End of 5.0 tests
|
|
972 |
||
973 |