WHERE 子句中的 HIVE SQL 子查询

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26124536/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 02:43:32  来源:igfitidea点击:

HIVE SQL Subquery in WHERE Clause

sqlhive

提问by user2715877

I have two tables with similar fields but the query is failing when I am doing a SELECTsubquery in a WHEREclause.

我有两个具有相似字段的表,但是当我SELECTWHERE子句中执行子查询时查询失败。

SELECT foo 
FROM   bar
WHERE  fizz IN (SELECT fizz FROM fuzz)

I deleted the error.logfrom AWS but the error was something to the extent that HIVE did not recognize the SELECT.

error.log从 AWS 中删除了,但错误的程度是 HIVE 无法识别SELECT.

How do I need to restructure this query?

我需要如何重构此查询?

Thanks.

谢谢。

回答by Myles Baker

From the Subqueries in the WHERE Clause section of the HIVE Language Manual:

来自HIVE 语言手册WHERE 子句部分的子查询:

SELECT b.foo FROM bar b WHERE b.fizz IN (SELECT f.fizz FROM fuzz f)

回答by Mihai

Hive has problems with subquery in the WHERE clause use a JOIN

Hive 在 WHERE 子句中使用 JOIN 的子查询有问题

SELECT foo FROM bar 
JOIN fuzz
ON bar.fizz=fuzz.fizz

回答by Prasanna

Hive does not support IN, EXISTS or subqueries in the WHERE clause. Go for a cross join...

Hive 不支持 WHERE 子句中的 IN、EXISTS 或子查询。去交叉连接...