Melissa Stewart
Melissa Stewart

Reputation: 3625

Hive multiple joins failing

I'm running the following query on hive,

SELECT a, b, c, d, e FROM A JOIN B ON A.a = B.a JOIN C ON A.b = C.a LIMIT 10;

I keep getting the following error,

Error while compiling statement: FAILED: SemanticException Column a Found in more than One Tables/Subqueries

Upvotes: 0

Views: 545

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270873

Whenever you have more than one table in a query, qualify all column names:

SELECT a.a, ?.b, ?.c, ?.d, ?.e 
FROM A JOIN
     B 
     ON A.a = B.a JOIN
     C 
     ON A.b = C.a
LIMIT 10;

The ? is for the tables where those columns come from. ALso, it is a bit unorthodox to use LIMIT without an ORDER BY.

Upvotes: 1

Related Questions