219
create table t1 (a int);
219
create table t1 (a int) ENGINE=MYISAM;
220
220
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
221
create temporary table t2 (a int, filler char(200), key(a)) engine=myisam;
222
insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C where A.a < 10;
221
create table t2 (a int, filler char(200), key(a)) ENGINE=MYISAM;
222
insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C;
223
223
insert into t2 select C.a*2+1, 'yes' from t1 C;
225
225
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
226
226
id select_type table type possible_keys key key_len ref rows Extra
227
1 SIMPLE t2 range a a 5 NULL 12 Using where
227
1 SIMPLE t2 range a a 5 NULL 12 Using where; Using MRR
228
228
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
240
240
explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2);
241
241
id select_type table type possible_keys key key_len ref rows Extra
242
1 SIMPLE t2 range a a 5 NULL 912 Using where
242
1 SIMPLE t2 range a a 5 NULL 912 Using where; Using MRR
243
243
explain select * from t2 force index(a) where a <> 2;
244
244
id select_type table type possible_keys key key_len ref rows Extra
245
1 SIMPLE t2 range a a 5 NULL 912 Using where
245
1 SIMPLE t2 range a a 5 NULL 912 Using where; Using MRR
247
247
create table t2 (a datetime, filler char(200), key(a));
248
248
insert into t2 select '2006-04-25 10:00:00' + interval C.a minute,
254
254
'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00',
255
255
'2006-04-25 10:06:00', '2006-04-25 10:08:00');
256
256
id select_type table type possible_keys key key_len ref rows Extra
257
1 SIMPLE t2 range a a 9 NULL 11 Using where
257
1 SIMPLE t2 range a a 9 NULL 20 Using where; Using MRR
258
258
select * from t2 where a NOT IN (
259
259
'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00',
260
260
'2006-04-25 10:06:00', '2006-04-25 10:08:00');
271
271
2006-04-25 10:19:00 yes
273
273
create table t2 (a varchar(10), filler char(200), key(a));
274
insert into t2 select 'foo', 'no' from t1 A, t1 B where A.a < 10;
275
insert into t2 select 'barbar', 'no' from t1 A, t1 B where A.a < 10;
276
insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B where A.a < 10;
274
insert into t2 select 'foo', 'no' from t1 A, t1 B;
275
insert into t2 select 'barbar', 'no' from t1 A, t1 B;
276
insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B;
277
277
insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'),
278
278
('barbas','1'), ('bazbazbay', '1'),('zz','1');
279
279
explain select * from t2 where a not in('foo','barbar', 'bazbazbaz');
280
280
id select_type table type possible_keys key key_len ref rows Extra
281
1 SIMPLE t2 range a a 43 NULL 5 Using where
281
1 SIMPLE t2 range a a 43 NULL 5 Using where; Using MRR
283
283
create table t2 (a decimal(10,5), filler char(200), key(a));
284
insert into t2 select 345.67890, 'no' from t1 A, t1 B where A.a < 10;
285
insert into t2 select 43245.34, 'no' from t1 A, t1 B where A.a < 10;
286
insert into t2 select 64224.56344, 'no' from t1 A, t1 B where A.a < 10;
284
insert into t2 select 345.67890, 'no' from t1 A, t1 B;
285
insert into t2 select 43245.34, 'no' from t1 A, t1 B;
286
insert into t2 select 64224.56344, 'no' from t1 A, t1 B;
287
287
insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'),
288
288
(55555,'1'), (77777, '1');
290
290
select * from t2 where a not in (345.67890, 43245.34, 64224.56344);
291
291
id select_type table type possible_keys key key_len ref rows Extra
292
1 SIMPLE t2 range a a 7 NULL 4 Using where
292
1 SIMPLE t2 range a a 7 NULL 4 Using where; Using MRR
293
293
select * from t2 where a not in (345.67890, 43245.34, 64224.56344);
304
304
set @str="update t2 set b=1 where a not in (";
305
305
select count(*) from (
306
306
select @str:=concat(@str, @cnt:=@cnt+1, ",")
307
from t1 A, t1 B, t1 C, t1 D where A.a < 10) Z;
307
from t1 A, t1 B, t1 C, t1 D) Z;
310
310
set @str:=concat(@str, "10000)");
349
349
JOIN t2 ON t3.a=t2.a
350
350
JOIN t4 WHERE t4.a IN (t1.b, t2.b);
351
351
id select_type table type possible_keys key key_len ref rows Extra
352
1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 4 Using index
352
353
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
353
354
1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 5 Using where; Using join buffer
354
1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 4 Using index
355
355
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 7 Range checked for each record (index map: 0x1)
356
356
SELECT STRAIGHT_JOIN * FROM t3
357
357
JOIN t1 ON t3.a=t1.a
368
368
WHERE t3.a=t1.a AND t3.a=t2.a;
369
369
id select_type table type possible_keys key key_len ref rows Extra
370
1 PRIMARY t3 index PRIMARY PRIMARY 4 NULL 4 Using index
370
371
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
371
372
1 PRIMARY t2 ALL PRIMARY NULL NULL NULL 5 Using where; Using join buffer
372
1 PRIMARY t3 index PRIMARY PRIMARY 4 NULL 4 Using index
373
373
2 DEPENDENT SUBQUERY t4 index NULL PRIMARY 4 NULL 7 Using where; Using index
374
374
SELECT STRAIGHT_JOIN
375
375
(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))
457
457
CREATE TABLE t1 (id int not null);
458
458
INSERT INTO t1 VALUES (1),(2);
459
459
SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) );
460
ERROR 22012: Division by 0
462
Error 1365 Division by 0
463
Error 1365 Division by 0
463
create TEMPORARY table t1(f1 char(1)) ENGINE=MYISAM;
466
create table t1(f1 char(1)) ENGINE=MYISAM;
464
467
insert into t1 values ('a'),('b'),('1');
465
468
select f1 from t1 where f1 in ('a',1);
492
495
explain select f1 from t1 where f1 in (2,1);
493
496
id select_type table type possible_keys key key_len ref rows Extra
494
497
1 SIMPLE t1 index t1f1_idx t1f1_idx 7 NULL 3 Using where; Using index
495
create TEMPORARY table t2(f2 int, index t2f2(f2)) ENGINE=MYISAM;
498
create table t2(f2 int, index t2f2(f2)) ENGINE=MYISAM;
496
499
insert into t2 values(0),(1),(2);
497
500
select f2 from t2 where f2 in ('a',2);
528
531
id select_type table type possible_keys key key_len ref rows Extra
529
532
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
530
533
drop table t1, t2;
531
create table t1 (a datetime, key(a));
534
create table t1 (a time, key(a));
532
535
insert into t1 values (),(),(),(),(),(),(),(),(),();
533
536
select a from t1 where a not in (a,a,a) group by a;