1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# from intersect.test
create table t1 (a int, b blob) engine=MyISAM;
create table t2 (c int, d blob) engine=MyISAM;
create table t3 (e int, f blob) engine=MyISAM;
insert into t1 values (5,5),(6,6);
insert into t2 values (2,2),(3,3);
insert into t3 values (1,1),(3,3);
set SQL_MODE=ORACLE;
(select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4);
explain extended
(select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4);
(select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4);
explain extended
(select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4);
create table t12(c1 int);
insert into t12 values(1);
insert into t12 values(2);
create table t13(c1 int);
insert into t13 values(1);
insert into t13 values(3);
create table t234(c1 int);
insert into t234 values(2);
insert into t234 values(3);
insert into t234 values(4);
select * from t13 union select * from t234 intersect select * from t12;
set SQL_MODE=default;
drop table t1,t2,t3;
drop table t12,t13, t234;
#from intersect_all.test
create table t1 (a int, b blob) engine=MyISAM;
create table t2 (c int, d blob) engine=MyISAM;
create table t3 (e int, f blob) engine=MyISAM;
insert into t1 values (5,5),(6,6);
insert into t2 values (2,2),(3,3);
insert into t3 values (1,1),(3,3);
set SQL_MODE=ORACLE;
select a,b from t1 union all select c,d from t2 intersect select e,f from t3 union all select 4,'4' from dual;
explain extended
select a,b from t1 union all select c,d from t2 intersect select e,f from t3 union all select 4,'4' from dual;
select a,b from t1 union all select c,d from t2 intersect all select e,f from t3 union all select 4,'4' from dual;
explain extended
select a,b from t1 union all select c,d from t2 intersect all select e,f from t3 union all select 4,'4' from dual;
select e,f from t3 intersect select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual;
explain extended
select e,f from t3 intersect select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual;
select e,f from t3 intersect all select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual;
explain extended
select e,f from t3 intersect all select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual;
set SQL_MODE=default;
drop table t1,t2,t3;
set SQL_MODE=oracle;
--error ER_NO_SUCH_TABLE
select * from t13 union select * from t234 intersect all select * from t12;
set SQL_MODE=default;
|