使用on子句进行左连接,但出现错误:“在连接中遇到左右别名”,并使用where子句,但过滤空值

时间:2019-05-15 09:34:22

标签: sql hive hiveql

我正在使用代码:

 create table table3 as
    select a.*,b.* 
    from
    table1 a
    left join
    table2 b
    on a.id=b.id
    where a.date>=b.date
    and a.age<b.age

但是,table1有20000行,而table3只有5000行。似乎where子句过滤了所有空值。

当我使用代码时:

create table table4 as
        select a.*,b.* 
        from
        table1 a
        left join
        table2 b
        on (a.id=b.id
        and a.date>=b.date
        and a.age<b.age)

因为在连接条件中使用了不等式,所以会出现错误“在连接中遇到左右别名”。

那么,如何通过使用左联接获得超过20000行包含空值?我应该多次联接还是可以使用另一种更有效的方法?

0 个答案:

没有答案
相关问题