代码之家  ›  专栏  ›  技术社区  ›  AbtPst

配置单元:无法执行带限制的联合查询

  •  0
  • AbtPst  · 技术社区  · 7 年前

    我正试图在hive中运行union all查询

    select * from tabName where col1='val1' and col2 = 'val2' limit 10 union all select * from tabName where col1='val1' and col2 = 'val3' limit 10;
    

    但我得到

    FAILED: ParseException line 1:105 missing EOF at 'union' near '10'
    

    我也尝试过

    ( select * from tabName where col1='val1' and col2 = 'val2' limit 10 ) as a union all ( select * from tabName where col1='val1' and col2 = 'val3' limit 10 ) as b;
    

    但我得到了

    FAILED: ParseException line 1:109 missing EOF at 'as' near ')'
    

    我做错什么了?

    0 回复  |  直到 7 年前
        1
  •  2
  •   leftjoin    7 年前

    使用从子查询中选择:

    select * from
    ( select * from tabName where col1='val1' and col2 = 'val2' limit 10 ) a 
    union all 
    select * from
    ( select * from tabName where col1='val1' and col2 = 'val3' limit 10 ) b;