2019-01-29 12:38:53 +00:00
|
|
|
drop table if exists X;
|
|
|
|
drop table if exists Y;
|
|
|
|
|
|
|
|
create table X (id Int32, x_name String) engine Memory;
|
|
|
|
create table Y (id Int32, y_name String) engine Memory;
|
|
|
|
|
|
|
|
insert into X (id, x_name) values (1, 'A'), (2, 'B'), (2, 'C'), (3, 'D'), (4, 'E'), (4, 'F'), (5, 'G'), (8, 'H'), (9, 'I');
|
|
|
|
insert into Y (id, y_name) values (1, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (3, 'e'), (4, 'f'), (6, 'g'), (7, 'h'), (9, 'i');
|
|
|
|
|
|
|
|
select 'inner';
|
2022-01-31 22:25:35 +00:00
|
|
|
select X.*, Y.* from X inner join Y using id order by X.id, Y.id, X.x_name, Y.y_name;
|
2019-01-29 12:38:53 +00:00
|
|
|
select 'inner subs';
|
2022-01-31 22:25:35 +00:00
|
|
|
select s.*, j.* from (select * from X) as s inner join (select * from Y) as j using id order by s.id, s.id, s.x_name, j.y_name;
|
2019-01-29 12:38:53 +00:00
|
|
|
|
|
|
|
select 'left';
|
2022-01-31 22:25:35 +00:00
|
|
|
select X.*, Y.* from X left join Y using id order by X.id, Y.id, X.x_name, Y.y_name;
|
2019-01-29 12:38:53 +00:00
|
|
|
select 'left subs';
|
2022-01-31 22:25:35 +00:00
|
|
|
select s.*, j.* from (select * from X) as s left join (select * from Y) as j using id order by s.id, j.id, s.x_name, j.y_name;
|
2019-01-29 12:38:53 +00:00
|
|
|
|
2019-01-31 18:10:16 +00:00
|
|
|
select 'right';
|
2022-01-31 22:25:35 +00:00
|
|
|
select X.*, Y.* from X right join Y using id order by X.id, Y.id, X.x_name, Y.y_name;
|
2019-01-31 18:10:16 +00:00
|
|
|
select 'right subs';
|
2022-01-31 22:25:35 +00:00
|
|
|
select s.*, j.* from (select * from X) as s right join (select * from Y) as j using id order by s.id, j.id, s.x_name, j.y_name;
|
2019-01-29 12:38:53 +00:00
|
|
|
|
2019-01-31 18:10:16 +00:00
|
|
|
select 'full';
|
2022-02-09 11:23:20 +00:00
|
|
|
select X.*, Y.* from X full join Y using id order by X.id, Y.id, X.x_name, Y.y_name;
|
2019-01-31 18:10:16 +00:00
|
|
|
select 'full subs';
|
2022-01-31 22:25:35 +00:00
|
|
|
select s.*, j.* from (select * from X) as s full join (select * from Y) as j using id order by s.id, j.id, s.x_name, j.y_name;
|
2019-01-29 12:38:53 +00:00
|
|
|
|
|
|
|
drop table X;
|
|
|
|
drop table Y;
|