mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 05:52:27 +01:00
e5b5f45319
fixed bug in sum function in subselect mysql-test/r/subselect.result: subselect in having clause mysql-test/t/subselect.test: subselect in having clause sql/item.cc: subselect in having clause sql/item.h: subselect in having clause sql/item_cmpfunc.cc: subselect in having clause sql/item_cmpfunc.h: subselect in having clause sql/item_func.cc: subselect in having clause sql/item_func.h: subselect in having clause sql/item_strfunc.h: subselect in having clause sql/item_subselect.cc: subselect in having clause sql/item_subselect.h: subselect in having clause sql/item_uniq.h: subselect in having clause sql/sql_base.cc: subselect in having clause sql/sql_class.cc: subselect in having clause sql/sql_class.h: subselect in having clause sql/sql_handler.cc: subselect in having clause sql/sql_lex.cc: subselect in having clause sql/sql_lex.h: subselect in having clause sql/sql_prepare.cc: subselect in having clause sql/sql_yacc.yy: subselect in having clause
85 lines
2.4 KiB
Text
85 lines
2.4 KiB
Text
select (select 2);
|
|
(select 2)
|
|
2
|
|
drop table if exists t1,t2,t3,t4;
|
|
create table t1 (a int);
|
|
create table t2 (a int, b int);
|
|
create table t3 (a int);
|
|
create table t4 (a int, b int);
|
|
insert into t1 values (2);
|
|
insert into t2 values (1,7),(2,7);
|
|
insert into t4 values (4,8),(3,8),(5,9);
|
|
select (select a from t1 where t1.a=t2.a), a from t2;
|
|
(select a from t1 where t1.a=t2.a) a
|
|
NULL 1
|
|
2 2
|
|
select (select a from t1 where t1.a=t2.b), a from t2;
|
|
(select a from t1 where t1.a=t2.b) a
|
|
NULL 1
|
|
NULL 2
|
|
select (select a from t1), a from t2;
|
|
(select a from t1) a
|
|
2 1
|
|
2 2
|
|
select (select a from t3), a from t2;
|
|
(select a from t3) a
|
|
NULL 1
|
|
NULL 2
|
|
select * from t2 where t2.a=(select a from t1);
|
|
a b
|
|
2 7
|
|
insert into t3 values (6),(7),(3);
|
|
select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1);
|
|
a b
|
|
1 7
|
|
2 7
|
|
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;
|
|
a b
|
|
1 7
|
|
2 7
|
|
3 8
|
|
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);
|
|
a b
|
|
1 7
|
|
2 7
|
|
3 8
|
|
4 8
|
|
select (select a from t3 where a<t2.a*4 order by 1 desc limit 1), a from t2;
|
|
(select a from t3 where a<t2.a*4 order by 1 desc limit 1) a
|
|
3 1
|
|
7 2
|
|
select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
|
|
(select * from t2 where a>1) as tt;
|
|
(select t3.a from t3 where a<8 order by 1 desc limit 1) a
|
|
7 2
|
|
select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
|
|
a
|
|
2
|
|
select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a > t1.a) order by 1 desc limit 1);
|
|
a
|
|
2
|
|
select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1);
|
|
a
|
|
select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4;
|
|
b (select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)
|
|
8 7.5000
|
|
8 4.5000
|
|
9 7.5000
|
|
select * from t3 where exists (select * from t2 where t2.b=t3.a);
|
|
a
|
|
7
|
|
select * from t3 where not exists (select * from t2 where t2.b=t3.a);
|
|
a
|
|
6
|
|
3
|
|
insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9);
|
|
select b,max(a) as ma from t4 group by b having b < (select max(t2.a)
|
|
from t2 where t2.b=t4.b);
|
|
b ma
|
|
select b,max(a) as ma from t4 group by b having b >= (select max(t2.a)
|
|
from t2 where t2.b=t4.b);
|
|
b ma
|
|
7 12
|
|
drop table t1,t2,t3,t4;
|