902
902
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using index
903
903
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer
905
Note 1003 select "test"."t1"."a" AS "a",<in_optimizer>("test"."t1"."a",<exists>(select 1 AS "Not_used" from "test"."t2" join "test"."t3" where (("test"."t3"."a" = "test"."t2"."a") and ((<cache>("test"."t1"."a") = "test"."t2"."a") or isnull("test"."t2"."a"))) having <is_not_null_test>("test"."t2"."a"))) AS "t1.a in (select t2.a from t2,t3 where t3.a=t2.a)" from "test"."t1"
905
Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
906
906
drop table t1,t2,t3;
907
create table t1 (a float);
908
select 10.5 IN (SELECT * from t1 LIMIT 1);
909
ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
910
select 10.5 IN (SELECT * from t1 LIMIT 1 UNION SELECT 1.5);
911
ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
913
create table t1 (a int, b int, c varchar(10));
914
create table t2 (a int);
915
insert into t1 values (1,2,'a'),(2,3,'b'),(3,4,'c');
916
insert into t2 values (1),(2),(NULL);
917
select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,2,'a'),(select c from t1 where a=t2.a) from t2;
918
a (select a,b,c from t1 where t1.a=t2.a) = ROW(a,2,'a') (select c from t1 where a=t2.a)
922
select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b'),(select c from t1 where a=t2.a) from t2;
923
a (select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b') (select c from t1 where a=t2.a)
927
select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,4,'c'),(select c from t1 where a=t2.a) from t2;
928
a (select a,b,c from t1 where t1.a=t2.a) = ROW(a,4,'c') (select c from t1 where a=t2.a)
933
create table t1 (a int, b real, c varchar(10));
934
insert into t1 values (1, 1, 'a'), (2,2,'b'), (NULL, 2, 'b');
935
select ROW(1, 1, 'a') IN (select a,b,c from t1);
936
ROW(1, 1, 'a') IN (select a,b,c from t1)
938
select ROW(1, 2, 'a') IN (select a,b,c from t1);
939
ROW(1, 2, 'a') IN (select a,b,c from t1)
941
select ROW(1, 1, 'a') IN (select b,a,c from t1);
942
ROW(1, 1, 'a') IN (select b,a,c from t1)
944
select ROW(1, 1, 'a') IN (select a,b,c from t1 where a is not null);
945
ROW(1, 1, 'a') IN (select a,b,c from t1 where a is not null)
947
select ROW(1, 2, 'a') IN (select a,b,c from t1 where a is not null);
948
ROW(1, 2, 'a') IN (select a,b,c from t1 where a is not null)
950
select ROW(1, 1, 'a') IN (select b,a,c from t1 where a is not null);
951
ROW(1, 1, 'a') IN (select b,a,c from t1 where a is not null)
953
select ROW(1, 1, 'a') IN (select a,b,c from t1 where c='b' or c='a');
954
ROW(1, 1, 'a') IN (select a,b,c from t1 where c='b' or c='a')
956
select ROW(1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a');
957
ROW(1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a')
959
select ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a');
960
ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a')
962
select ROW(1, 1, 'a') IN (select b,a,c from t1 limit 2);
963
ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
965
907
CREATE TABLE t1 (a int);
966
908
EXPLAIN EXTENDED SELECT (SELECT RAND() FROM t1) FROM t1;
967
909
id select_type table type possible_keys key key_len ref rows filtered Extra
968
910
1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00
969
911
2 SUBQUERY t1 ALL NULL NULL NULL NULL 1 100.00
971
Note 1003 select (select rand() AS "RAND()" from "test"."t1") AS "(SELECT RAND() FROM t1)" from "test"."t1"
913
Note 1003 select (select rand() AS `RAND()` from `test`.`t1`) AS `(SELECT RAND() FROM t1)` from `test`.`t1`
972
914
EXPLAIN EXTENDED SELECT (SELECT BENCHMARK(1,1) FROM t1) FROM t1;
973
915
id select_type table type possible_keys key key_len ref rows filtered Extra
974
916
1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00
975
917
2 SUBQUERY t1 ALL NULL NULL NULL NULL 1 100.00
977
Note 1003 select (select benchmark(1,1) AS "BENCHMARK(1,1)" from "test"."t1") AS "(SELECT BENCHMARK(1,1) FROM t1)" from "test"."t1"
919
Note 1003 select (select benchmark(1,1) AS `BENCHMARK(1,1)` from `test`.`t1`) AS `(SELECT BENCHMARK(1,1) FROM t1)` from `test`.`t1`
979
921
CREATE TABLE `t1` (
980
922
`mot` varchar(30) character set latin1 NOT NULL default '',
993
935
PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`),
994
936
KEY `pseudo` (`pseudo`,`date`,`topic`),
995
937
KEY `topic` (`topic`)
996
) ENGINE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
938
) ENGINE=MyISAM ROW_FORMAT=DYNAMIC;
997
939
CREATE TABLE `t3` (
998
940
`numeropost` bigint unsigned NOT NULL auto_increment,
999
941
`maxnumrep` int unsigned NOT NULL default '0',
1000
942
PRIMARY KEY (`numeropost`),
1001
943
UNIQUE KEY `maxnumrep` (`maxnumrep`)
1002
) ENGINE=MyISAM CHARSET=latin1;
1003
945
INSERT INTO t1 (mot, topic, pseudo) VALUES ('joce','1','joce'),('test','2','test');
1004
946
INSERT INTO t2 (mot, topic, pseudo) VALUES ('joce','1','joce'),('test','2','test');
1005
947
INSERT INTO t3 VALUES (1,1);
1399
1333
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
1400
1334
id select_type table type possible_keys key key_len ref rows filtered Extra
1401
1 PRIMARY t1 index NULL s1 8 NULL 3 100.00 Using index
1402
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 8 func 2 100.00 Using index; Full scan on NULL key
1335
1 PRIMARY t1 index NULL s1 23 NULL 3 100.00 Using index
1336
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 23 func 2 100.00 Using index; Full scan on NULL key
1404
Note 1003 select "test"."t1"."s1" AS "s1",(not(<in_optimizer>("test"."t1"."s1",<exists>(<index_lookup>(<cache>("test"."t1"."s1") in t2 on s1 checking NULL having trigcond(<is_not_null_test>("test"."t2"."s1"))))))) AS "s1 NOT IN (SELECT s1 FROM t2)" from "test"."t1"
1338
Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
1405
1339
explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1;
1406
1340
id select_type table type possible_keys key key_len ref rows filtered Extra
1407
1 PRIMARY t1 index NULL s1 8 NULL 3 100.00 Using index
1408
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 8 func 2 100.00 Using index; Full scan on NULL key
1341
1 PRIMARY t1 index NULL s1 23 NULL 3 100.00 Using index
1342
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 23 func 2 100.00 Using index; Full scan on NULL key
1410
Note 1003 select "test"."t1"."s1" AS "s1",<in_optimizer>("test"."t1"."s1",<exists>(<index_lookup>(<cache>("test"."t1"."s1") in t2 on s1 checking NULL having trigcond(<is_not_null_test>("test"."t2"."s1"))))) AS "s1 = ANY (SELECT s1 FROM t2)" from "test"."t1"
1344
Note 1003 select `test`.`t1`.`s1` AS `s1`,<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
1411
1345
explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1;
1412
1346
id select_type table type possible_keys key key_len ref rows filtered Extra
1413
1 PRIMARY t1 index NULL s1 8 NULL 3 100.00 Using index
1414
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 8 func 2 100.00 Using index; Full scan on NULL key
1347
1 PRIMARY t1 index NULL s1 23 NULL 3 100.00 Using index
1348
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 23 func 2 100.00 Using index; Full scan on NULL key
1416
Note 1003 select "test"."t1"."s1" AS "s1",(not(<in_optimizer>("test"."t1"."s1",<exists>(<index_lookup>(<cache>("test"."t1"."s1") in t2 on s1 checking NULL having trigcond(<is_not_null_test>("test"."t2"."s1"))))))) AS "s1 <> ALL (SELECT s1 FROM t2)" from "test"."t1"
1350
Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
1417
1351
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
1418
1352
id select_type table type possible_keys key key_len ref rows filtered Extra
1419
1 PRIMARY t1 index NULL s1 8 NULL 3 100.00 Using index
1420
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 8 func 2 100.00 Using index; Using where; Full scan on NULL key
1353
1 PRIMARY t1 index NULL s1 23 NULL 3 100.00 Using index
1354
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 23 func 2 100.00 Using index; Using where; Full scan on NULL key
1422
Note 1003 select "test"."t1"."s1" AS "s1",(not(<in_optimizer>("test"."t1"."s1",<exists>(<index_lookup>(<cache>("test"."t1"."s1") in t2 on s1 checking NULL where ("test"."t2"."s1" < 'a2') having trigcond(<is_not_null_test>("test"."t2"."s1"))))))) AS "s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')" from "test"."t1"
1356
Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1`
1423
1357
drop table t1,t2;
1424
1358
create table t2 (a int, b int);
1425
1359
create table t3 (a int);
1504
1438
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
1505
1439
2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary; Using filesort
1507
Note 1003 select "test"."t3"."a" AS "a" from "test"."t3" where <not>(("test"."t3"."a" <= <max>(select max("test"."t2"."b") AS "max(b)" from "test"."t2" group by "test"."t2"."a")))
1441
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` <= <max>(select max(`test`.`t2`.`b`) AS `max(b)` from `test`.`t2` group by `test`.`t2`.`a`)))
1508
1442
drop table t2, t3;
1509
CREATE TABLE `t1` ( `id` bigint NOT NULL auto_increment, `taskid` bigint NOT NULL default '0', `dbid` int NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ;
1443
CREATE TABLE `t1` ( `id` bigint NOT NULL auto_increment, `taskid` bigint NOT NULL default '0', `dbid` int NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM AUTO_INCREMENT=3 ;
1510
1444
INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now());
1511
CREATE TABLE `t2` (`db_id` int NOT NULL auto_increment,`name` varchar(200) NOT NULL default '',`primary_uid` smallint NOT NULL default '0',`secondary_uid` smallint NOT NULL default '0',PRIMARY KEY (`db_id`),UNIQUE KEY `name_2` (`name`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=2147483647;
1445
CREATE TABLE `t2` (`db_id` int NOT NULL auto_increment,`name` varchar(200) NOT NULL default '',`primary_uid` smallint NOT NULL default '0',`secondary_uid` smallint NOT NULL default '0',PRIMARY KEY (`db_id`),UNIQUE KEY `name_2` (`name`)) ENGINE=MyISAM AUTO_INCREMENT=2147483647;
1512
1446
INSERT INTO `t2` (`db_id`, `name`, `primary_uid`, `secondary_uid`) VALUES (18, 'Not Set 1', 0, 0),(19, 'Valid', 1, 2),(20, 'Valid 2', 1, 2),(21, 'Should Not Return', 1, 2),(26, 'Not Set 2', 0, 0),(-1, 'ALL DB\'S', 0, 0);
1513
CREATE TABLE `t3` (`taskgenid` bigint NOT NULL auto_increment,`dbid` int NOT NULL default '0',`taskid` int NOT NULL default '0',`mon` tinyint NOT NULL default '1',`tues` tinyint NOT NULL default '1',`wed` tinyint NOT NULL default '1',`thur` tinyint NOT NULL default '1',`fri` tinyint NOT NULL default '1',`sat` tinyint NOT NULL default '0',`sun` tinyint NOT NULL default '0',`how_often` smallint NOT NULL default '1',`userid` smallint NOT NULL default '0',`active` tinyint NOT NULL default '1',PRIMARY KEY (`taskgenid`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=2 ;
1447
CREATE TABLE `t3` (`taskgenid` bigint NOT NULL auto_increment,`dbid` int NOT NULL default '0',`taskid` int NOT NULL default '0',`mon` tinyint NOT NULL default '1',`tues` tinyint NOT NULL default '1',`wed` tinyint NOT NULL default '1',`thur` tinyint NOT NULL default '1',`fri` tinyint NOT NULL default '1',`sat` tinyint NOT NULL default '0',`sun` tinyint NOT NULL default '0',`how_often` smallint NOT NULL default '1',`userid` smallint NOT NULL default '0',`active` tinyint NOT NULL default '1',PRIMARY KEY (`taskgenid`)) ENGINE=MyISAM AUTO_INCREMENT=2 ;
1514
1448
INSERT INTO `t3` (`taskgenid`, `dbid`, `taskid`, `mon`, `tues`,`wed`, `thur`, `fri`, `sat`, `sun`, `how_often`, `userid`, `active`) VALUES (1,-1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1);
1515
CREATE TABLE `t4` (`task_id` smallint NOT NULL default '0',`description` varchar(200) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
1449
CREATE TABLE `t4` (`task_id` smallint NOT NULL default '0',`description` varchar(200) NOT NULL default '') ENGINE=MyISAM;
1516
1450
INSERT INTO `t4` (`task_id`, `description`) VALUES (1, 'Daily Check List'),(2, 'Weekly Status');
1517
1451
select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid;
1518
1452
dbid name (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01')
1656
1590
1 PRIMARY t1 ALL NULL NULL NULL NULL 12 100.00 Using where
1657
1591
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where
1659
Note 1003 select "test"."t1"."id" AS "id","test"."t1"."text" AS "text" from "test"."t1" where (not(<in_optimizer>("test"."t1"."id",<exists>(<primary_index_lookup>(<cache>("test"."t1"."id") in t1 on PRIMARY where (("test"."t1"."id" < 8) and (<cache>("test"."t1"."id") = "test"."t1"."id")))))))
1593
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where ((`test`.`t1`.`id` < 8) and (<cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`)))))))
1660
1594
explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null);
1661
1595
id select_type table type possible_keys key key_len ref rows filtered Extra
1662
1596
1 PRIMARY tt ALL NULL NULL NULL NULL 12 100.00 Using where
1663
1597
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
1665
1599
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
1666
Note 1003 select "test"."tt"."id" AS "id","test"."tt"."text" AS "text" from "test"."t1" "tt" where (not(exists(select "test"."t1"."id" AS "id" from "test"."t1" where (("test"."t1"."id" < 8) and ("test"."t1"."id" = "test"."tt"."id")) having ("test"."t1"."id" is not null))))
1600
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(exists(select `test`.`t1`.`id` AS `id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null))))
1667
1601
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
1668
1602
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
1669
1603
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
2527
2461
select (select * from t1) = (1,2,3);
2528
2462
ERROR 21000: Operand should contain 2 column(s)
2531
`itemid` bigint unsigned NOT NULL auto_increment,
2532
`sessionid` bigint unsigned default NULL,
2533
`time` int unsigned NOT NULL default '0',
2534
`type` set('A','D','E','F','G','I','L','N','U') collate latin1_general_ci NOT
2536
`data` text collate latin1_general_ci NOT NULL,
2537
PRIMARY KEY (`itemid`)
2538
) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
2539
INSERT INTO `t1` VALUES (1, 1, 1, 'D', '');
2541
`sessionid` bigint unsigned NOT NULL auto_increment,
2542
`pid` int unsigned NOT NULL default '0',
2543
`date` int unsigned NOT NULL default '0',
2544
`ip` varchar(15) collate latin1_general_ci NOT NULL default '',
2545
PRIMARY KEY (`sessionid`)
2546
) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
2547
INSERT INTO `t2` VALUES (1, 1, 1, '10.10.10.1');
2548
SELECT s.ip, count( e.itemid ) FROM `t1` e JOIN t2 s ON s.sessionid = e.sessionid WHERE e.sessionid = ( SELECT sessionid FROM t2 ORDER BY sessionid DESC LIMIT 1 ) GROUP BY s.ip HAVING count( e.itemid ) >0 LIMIT 0 , 30;
2549
ip count( e.itemid )
2552
2464
create table t1 (fld enum('0','1'));
2553
2465
insert into t1 values ('1');
2554
2466
select * from (select max(fld) from t1) as foo;
2625
2537
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
2626
2538
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
2628
Note 1003 select "test"."t1"."one" AS "one","test"."t1"."two" AS "two",<in_optimizer>(("test"."t1"."one","test"."t1"."two"),<exists>(select "test"."t2"."one" AS "one","test"."t2"."two" AS "two" from "test"."t2" where (("test"."t2"."flag" = '0') and trigcond(((<cache>("test"."t1"."one") = "test"."t2"."one") or isnull("test"."t2"."one"))) and trigcond(((<cache>("test"."t1"."two") = "test"."t2"."two") or isnull("test"."t2"."two")))) having (trigcond(<is_not_null_test>("test"."t2"."one")) and trigcond(<is_not_null_test>("test"."t2"."two"))))) AS "test" from "test"."t1"
2540
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1`
2629
2541
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
2630
2542
id select_type table type possible_keys key key_len ref rows filtered Extra
2631
2543
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 Start temporary
2632
2544
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; End temporary; Using join buffer
2634
Note 1003 select "test"."t1"."one" AS "one","test"."t1"."two" AS "two" from "test"."t1" semi join ("test"."t2") where (("test"."t2"."two" = "test"."t1"."two") and ("test"."t2"."one" = "test"."t1"."one") and ("test"."t2"."flag" = 'N'))
2546
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N'))
2635
2547
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
2636
2548
id select_type table type possible_keys key key_len ref rows filtered Extra
2637
2549
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
2638
2550
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary; Using filesort
2640
Note 1003 select "test"."t1"."one" AS "one","test"."t1"."two" AS "two",<in_optimizer>(("test"."t1"."one","test"."t1"."two"),<exists>(select "test"."t2"."one" AS "one","test"."t2"."two" AS "two" from "test"."t2" where ("test"."t2"."flag" = '0') group by "test"."t2"."one","test"."t2"."two" having (trigcond(((<cache>("test"."t1"."one") = "test"."t2"."one") or isnull("test"."t2"."one"))) and trigcond(((<cache>("test"."t1"."two") = "test"."t2"."two") or isnull("test"."t2"."two"))) and trigcond(<is_not_null_test>("test"."t2"."one")) and trigcond(<is_not_null_test>("test"."t2"."two"))))) AS "test" from "test"."t1"
2552
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1`
2641
2553
DROP TABLE t1,t2;
2642
2554
CREATE TABLE t1 (a char(5), b char(5));
2643
2555
INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa');
2970
2882
DROP TABLE t1,t2,t3;
2972
`itemid` bigint unsigned NOT NULL auto_increment,
2973
`sessionid` bigint unsigned default NULL,
2974
`time` int unsigned NOT NULL default '0',
2975
`type` set('A','D','E','F','G','I','L','N','U') collate latin1_general_ci NOT
2977
`data` text collate latin1_general_ci NOT NULL,
2978
PRIMARY KEY (`itemid`)
2979
) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
2980
INSERT INTO `t1` VALUES (1, 1, 1, 'D', '');
2982
`sessionid` bigint unsigned NOT NULL auto_increment,
2983
`pid` int unsigned NOT NULL default '0',
2984
`date` int unsigned NOT NULL default '0',
2985
`ip` varchar(15) collate latin1_general_ci NOT NULL default '',
2986
PRIMARY KEY (`sessionid`)
2987
) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
2988
INSERT INTO `t2` VALUES (1, 1, 1, '10.10.10.1');
2989
SELECT s.ip, count( e.itemid ) FROM `t1` e JOIN t2 s ON s.sessionid = e.sessionid WHERE e.sessionid = ( SELECT sessionid FROM t2 ORDER BY sessionid DESC LIMIT 1 ) GROUP BY s.ip HAVING count( e.itemid ) >0 LIMIT 0 , 30;
2990
ip count( e.itemid )
2993
2883
CREATE TABLE t1 (EMPNUM CHAR(3));
2994
2884
CREATE TABLE t2 (EMPNUM CHAR(3) );
2995
2885
INSERT INTO t1 VALUES ('E1'),('E2');