2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE IF EXISTS using1;
|
|
|
|
DROP TABLE IF EXISTS using2;
|
2018-08-31 10:30:57 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
CREATE TABLE using1(a UInt8, b UInt8) ENGINE=Memory;
|
|
|
|
CREATE TABLE using2(a UInt8, b UInt8) ENGINE=Memory;
|
2018-08-31 10:30:57 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
INSERT INTO using1 VALUES (1, 1) (2, 2) (3, 3);
|
|
|
|
INSERT INTO using2 VALUES (4, 4) (2, 2) (3, 3);
|
2018-08-31 10:30:57 +00:00
|
|
|
|
2023-02-19 20:14:22 +00:00
|
|
|
SELECT * FROM using1 ALL LEFT JOIN (SELECT * FROM using2) js2 USING (a, b) ORDER BY a;
|
2018-08-31 10:30:57 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE using1;
|
|
|
|
DROP TABLE using2;
|
2019-01-24 14:22:58 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
drop table if exists persons;
|
|
|
|
drop table if exists children;
|
|
|
|
|
|
|
|
create table persons (id String, name String) engine MergeTree order by id;
|
|
|
|
create table children (id String, childName String) engine MergeTree order by id;
|
|
|
|
|
|
|
|
insert into persons (id, name)
|
|
|
|
values ('1', 'John'), ('2', 'Jack'), ('3', 'Daniel'), ('4', 'James'), ('5', 'Amanda');
|
|
|
|
|
|
|
|
insert into children (id, childName)
|
|
|
|
values ('1', 'Robert'), ('1', 'Susan'), ('3', 'Sarah'), ('4', 'David'), ('4', 'Joseph'), ('5', 'Robert');
|
|
|
|
|
2022-07-07 15:57:15 +00:00
|
|
|
select * from persons all inner join children using id order by id, name, childName;
|
|
|
|
select * from persons all inner join (select * from children) as j using id order by id, name, childName;
|
|
|
|
select * from (select * from persons) as s all inner join (select * from children ) as j using id order by id, name, childName;
|
2019-01-24 14:22:58 +00:00
|
|
|
--
|
2019-09-02 12:53:31 +00:00
|
|
|
set joined_subquery_requires_alias = 0;
|
2022-07-07 15:57:15 +00:00
|
|
|
select * from persons all inner join (select * from children) using id order by id, name, childName;
|
|
|
|
select * from (select * from persons) all inner join (select * from children) using id order by id, name, childName;
|
|
|
|
select * from (select * from persons) as s all inner join (select * from children) using id order by id, name, childName;
|
2019-01-24 14:22:58 +00:00
|
|
|
|
|
|
|
drop table persons;
|
|
|
|
drop table children;
|