1
drop table if exists t1, t2;
2
create table t1 (a int) engine = blitzdb;
3
create table t2 (a int) engine = blitzdb;
4
insert into t1 values (1), (2), (3);
5
insert into t2 values (1), (4), (8);
6
select * from t1 JOIN t2 where t1.a = t2.a;
9
select * from t1 LEFT JOIN t2 on t1.a = t2.a;
14
select * from t1 RIGHT JOIN t2 on t1.a = t2.a;
19
select * from t1 UNION select * from t2;
27
create table t1 (id int, name varchar(32)) engine = blitzdb;
28
create table t2 (id int, job_id int) engine = blitzdb;
29
create table t3 (job_id int, job_name varchar(32)) engine = blitzdb;
30
insert into t1 values (1, 'Alex');
31
insert into t1 values (2, 'Bob');
32
insert into t1 values (3, 'Curt');
33
insert into t1 values (4, 'Dan');
34
insert into t1 values (5, 'Edgar');
35
insert into t2 values (1, 1);
36
insert into t2 values (2, 1);
37
insert into t2 values (3, 3);
38
insert into t2 values (4, 2);
39
insert into t2 values (5, 4);
40
insert into t3 values (1, 'Software Engineer');
41
insert into t3 values (2, 'Civil Engineer');
42
insert into t3 values (3, 'Electrical Engineer');
43
insert into t3 values (4, 'Mechanical Engineer');
49
(t1.id = t2.id and t2.job_id = t3.job_id);
51
Alex Software Engineer
53
Curt Electrical Engineer
55
Edgar Mechanical Engineer
59
t1 right join (t2, t3)
61
(t1.id = t2.id and t2.job_id = t3.job_id);
63
Alex Software Engineer
65
NULL Electrical Engineer
66
NULL Mechanical Engineer
69
NULL Electrical Engineer
70
NULL Mechanical Engineer
71
NULL Software Engineer
73
Curt Electrical Engineer
74
NULL Mechanical Engineer
75
NULL Software Engineer
77
NULL Electrical Engineer
78
NULL Mechanical Engineer
79
NULL Software Engineer
81
NULL Electrical Engineer
82
Edgar Mechanical Engineer
83
delete from t3 where job_id = 4;
89
(t1.id = t2.id and t2.job_id = t3.job_id);
91
Alex Software Engineer
93
Curt Electrical Engineer
100
(t1.id = t2.id and t2.job_id = t3.job_id);
102
Alex Software Engineer
103
Bob Software Engineer
104
Curt Electrical Engineer
107
drop table t1, t2, t3;