@@ -155,21 +155,18 @@ select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1);
...
@@ -155,21 +155,18 @@ select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1);
a b
a b
1 7
1 7
2 7
2 7
(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1))
(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 order by a limit 2) limit 3;
union (select * from t4 order by a limit 2) limit 3;
a b
a b
1 7
1 7
2 7
2 7
3 8
3 8
(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1))
(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
a b
a b
1 7
1 7
2 7
2 7
3 8
3 8
4 8
4 8
explain (select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1))
explain (select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
2 SUBSELECT t3 ALL NULL NULL NULL NULL 3 Using filesort
2 SUBSELECT t3 ALL NULL NULL NULL NULL 3 Using filesort
...
@@ -281,7 +278,7 @@ NULL 1
...
@@ -281,7 +278,7 @@ NULL 1
explain select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
explain select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBSELECT t1 system NULL NULL NULL NULL 1 Using where
2 DEPENDENT SUBSELECT t1 system NULL NULL NULL NULL 1
3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
Subselect returns more than 1 record
Subselect returns more than 1 record
...
@@ -324,9 +321,9 @@ INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
...
@@ -324,9 +321,9 @@ INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
EXPLAIN SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
EXPLAIN SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t8 const PRIMARY PRIMARY 35 const 1
1 PRIMARY t8 const PRIMARY PRIMARY 35 const 1
4 SUBSELECT t8 const PRIMARY PRIMARY 35 const 1
4 SUBSELECT t8 const PRIMARY PRIMARY 35 1
2 SUBSELECT t8 const PRIMARY PRIMARY 35 const 1
2 SUBSELECT t8 const PRIMARY PRIMARY 35 const 1
3 SUBSELECT t8 const PRIMARY PRIMARY 35 const 1
3 SUBSELECT t8 const PRIMARY PRIMARY 35 1
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
t8 WHERE pseudo='joce');
Cardinality error (more/less than 1 columns)
Cardinality error (more/less than 1 columns)
...
@@ -400,36 +397,51 @@ SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) b;
...
@@ -400,36 +397,51 @@ SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) b;
Unknown column 'a' in 'having clause'
Unknown column 'a' in 'having clause'
SELECT 1 IN (SELECT 1 FROM t2 HAVING a);
SELECT 1 IN (SELECT 1 FROM t2 HAVING a);
Unknown column 'a' in 'having clause'
Unknown column 'a' in 'having clause'
SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY date);
SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic);
mot topic date pseudo
mot topic date pseudo
joce 40143 2002-10-22 joce
joce 40143 2002-10-22 joce
joce 43506 2002-10-22 joce
joce 43506 2002-10-22 joce
SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY date HAVING topic < 4100);
SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
mot topic date pseudo
mot topic date pseudo
joce 43506 2002-10-22 joce
SELECT * from t2 where topic IN (SELECT SUM(topic) FROM t1);
SELECT * from t2 where topic IN (SELECT SUM(topic) FROM t1);
mot topic date pseudo
mot topic date pseudo
SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY date);
SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic);
mot topic date pseudo
mot topic date pseudo
joce 40143 2002-10-22 joce
joce 40143 2002-10-22 joce
joce 43506 2002-10-22 joce
joce 43506 2002-10-22 joce
SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY date HAVING topic < 4100);
SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
mot topic date pseudo
mot topic date pseudo
joce 43506 2002-10-22 joce
SELECT * from t2 where topic = any (SELECT SUM(topic) FROM t1);
SELECT * from t2 where topic = any (SELECT SUM(topic) FROM t1);
mot topic date pseudo
mot topic date pseudo
SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY date);
SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic);
mot topic date pseudo
mot topic date pseudo
joce 40143 2002-10-22 joce
SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY date HAVING topic < 4100);
mot topic date pseudo
mot topic date pseudo
joce 40143 2002-10-22 joce
joce 40143 2002-10-22 joce
joce 43506 2002-10-22 joce
SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2;
mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100)
joce 40143 2002-10-22 joce 1
joce 43506 2002-10-22 joce 1
SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2);
SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2);
mot topic date pseudo
mot topic date pseudo
SELECT * from t2 where topic <> any (SELECT SUM(topic) FROM t2);
SELECT * from t2 where topic <> any (SELECT SUM(topic) FROM t2);
mot topic date pseudo
mot topic date pseudo
joce 40143 2002-10-22 joce
joce 40143 2002-10-22 joce
joce 43506 2002-10-22 joce
joce 43506 2002-10-22 joce
SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
mot topic date pseudo
joce 40143 2002-10-22 joce
SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
mot topic date pseudo
joce 40143 2002-10-22 joce
SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
mot topic date pseudo
joce 40143 2002-10-22 joce
SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2;
mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000)
joce 40143 2002-10-22 joce 1
joce 43506 2002-10-22 joce 0
drop table t1,t2;
drop table t1,t2;
CREATE TABLE `t1` (
CREATE TABLE `t1` (
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
...
@@ -856,3 +868,86 @@ do (SELECT a from t1);
...
@@ -856,3 +868,86 @@ do (SELECT a from t1);
Table 'test.t1' doesn't exist
Table 'test.t1' doesn't exist
set @a:=(SELECT a from t1);
set @a:=(SELECT a from t1);
Table 'test.t1' doesn't exist
Table 'test.t1' doesn't exist
CREATE TABLE t1 (a int, KEY(a));
HANDLER t1 OPEN;
HANDLER t1 READ a=((SELECT 1));
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use
HANDLER t1 CLOSE;
drop table t1;
create table t1 (a int);
create table t2 (b int);
insert into t1 values (1),(2);
insert into t2 values (1);
select a from t1 where a in (select a from t1 where a in (select b from t2));
a
1
drop table t1, t2;
create table t1 (a int, b int);
create table t2 like t1;
insert into t1 values (1,2),(1,3),(1,4),(1,5);
insert into t2 values (1,2),(1,3);
select * from t1 where row(a,b) in (select a,b from t2);