1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#
#test for LP Bug#611379
#
create table t1 (a int not null);
insert into t1 values (1);
create table t2 (a int not null primary key);
insert into t2 values (10);
explain select sum(distinct t1.a) from t1,t2 where t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
explain select * from (select sum(distinct t1.a) from t1,t2 where t1.a=t2.a)
as t;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
2 DERIVED t1 ALL NULL NULL NULL NULL 1
2 DERIVED t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
select sum(distinct t1.a) from t1,t2 where t1.a=t2.a;
sum(distinct t1.a)
NULL
select * from (select sum(distinct t1.a) from t1,t2 where t1.a=t2.a) as t;
sum(distinct t1.a)
NULL
drop table t1,t2;
|