2017-01-23 15 views
0

我想在多列上留下外部連接表A和表B。下面是我的代碼:Impala:嘗試連接多個列時出現重複的表別名

select * from table_A 

    left outer join table_B 
    on (table_A.a1 = table_B.b1) 

    left outer join table_B 
    on (table_A.a2 = table_B.b2) 

但後來我得到了錯誤:

HiveServer2Error: AnalysisException: Duplicate table alias: 'table_B' 

有誰知道whatI做錯了嗎?謝謝!

回答

1

使用不同的表別名,因爲您要加入同一個表兩次。

select * -- use column names here instead of * 
from table_A ta 
left outer join table_B tb1 on (ta.a1 = tb1.b1) 
left outer join table_B tb2 on (ta.a2 = tb2.b2) 
相關問題