1
drop table if exists t1,t2;
2
create table t1(pk int primary key, c1 int, c2 int);
3
insert into t1 values(1,1,1),(2,2,2);
4
explain select * from t1 where c2=1 and c1=c2 and pk=c1;
5
select * from t1 where c2=1 and c1=c2 and pk=c1;
9
create table t1(pk int primary key, c1 int, c2 int, c3 int,c4 int , c5 int, c6 int, c7 int, c8 int, c9 int, c10 int);
10
insert into t1 values(1,1,1,1,1,1,1,1,1,1,1),(2,2,2,2,2,2,2,2,2,2,2),(3,2,2,2,3,2,3,2,3,3,3);
11
explain select * from t1 where c10=1 and c9=c10 and c8=c9 and c7=c8 and c6=c7 and c5=c6 and c4=c5 and c3=c4 and c2=c3 and c1=c2 and pk=c1;
12
select * from t1 where c10=1 and c9=c10 and c8=c9 and c7=c8 and c6=c7 and c5=c6 and c4=c5 and c3=c4 and c2=c3 and c1=c2 and pk=c1;
13
pk c1 c2 c3 c4 c5 c6 c7 c8 c9 c10
15
select * from t1 where c9=c10 and c8=c9 and c7=c8 and c6=c7 and c5=c6 and c4=c5 and c3=c4 and c2=c3 and c1=c2 and c10=1 and pk=c1;
16
pk c1 c2 c3 c4 c5 c6 c7 c8 c9 c10
18
select * from t1 where c9=c10 and c8=c9 and c7=c8 and c6=c7 and c5=c6 and c4=c5 and c3=c4 and c2=c3 and c1=c2 and pk=c1;
19
pk c1 c2 c3 c4 c5 c6 c7 c8 c9 c10
22
explain select * from t1 where c10>1 and c9=c10 and c8=c9 and c7=c8 and c6=c7 and c5=c6 and c4=c5 and c3=c4 and c2=c3 and c1=c2 and pk=c1;
23
select * from t1 where c10>1 and c9=c10 and c8=c9 and c7=c8 and c6=c7 and c5=c6 and c4=c5 and c3=c4 and c2=c3 and c1=c2 and pk=c1;
24
pk c1 c2 c3 c4 c5 c6 c7 c8 c9 c10
27
create table t1(pk int primary key, c1 int, c2 int);
28
insert into t1 values(1,1,1),(2,2,2);
29
create table t2(pk int primary key, c1 int, c2 int);
30
insert into t2 values(1,1,1),(2,2,2);
31
select t1.pk,t2.c2 from t1,t2 where t1.pk=t2.pk and t1.pk=1;
34
select t1.pk,t2.c2 from t1,t2 where t1.pk=t2.pk and t1.pk>1;
37
select t1.pk,t2.c2 from t1 INNER join t2 on t1.pk=t2.pk and t2.pk=1;
40
select t1.pk,t2.c2 from t1 LEFT join t2 on t1.pk=t2.pk and t2.pk=1;
44
explain select t1.pk,t2.c2 from t1 LEFT join t2 on t1.pk=t2.pk and t2.pk=1;
45
select t1.pk,t2.c2 from t1 RIGHT join t2 on t1.pk=t2.pk and t2.pk=1;
49
select t1.pk,t2.c2 from t1 FULL join t2 on t1.pk=t2.pk and t2.pk=1;