用这种数据
create table table_a as select 1 as id1;
insert into table_a values (2),(3);
create table table_b as select 1 as id1, 'a' as id2;
insert into table_b values (1,'b');
create table table_c as select 'a' as id2;
我在impala sql中有以下类型的连接:
select *
from table_a as a
left join table_b as b
on b.id1 = a.id1
left join table_c as c
on c.id2 = b.id2
产生这个结果
"id1","id1","id2","id2"
1,1,b,
1,1,a,a
2,,,
3,,,
我希望第二个连接是内部连接而不是左连接:
select *
from table_a as a
left join table_b as b
on b.id1 = a.id1
join table_c as c /* <- How to process this join first without using inner queries? */
on c.id2 = b.id2
得到这个结果:
"id1","id1","id2","id2"
1,1,a,a
2,,,
3,,,
因此,我希望 table_b
以及 table_c
先发生后做左连接 table_a
以及( table_b
内部连接到 table_b
).
不使用内部查询就可以以这种方式确定连接顺序吗?
1条答案
按热度按时间p3rjfoxz1#
在@jarlh的帮助下,我实现了从左到右的连接处理,然后发现可以使用右连接:
为了得到期望的结果: