我有两个基于此结构的表:

airports : code,value
fly : idFly,date, codeAirport1, codeAiport2

codeAirport1对应于起飞,codeAirport2对应于降落,因此它们是不同的。
我想获取codeAirport1和codeAirport2的值。我尝试了这个:
SELECT v1.codeAirport1, v2.codeAiport2
From airports
LEFT  JOIN fly v1 ON airports.code = v1.codeAirport1
LEFT JOIN fly v2 ON airports.code = v2.codeAiport2;

但是Hadoop中的工作是无限的,因为reduce步骤始终在运行并且永远不会完成。

提前致谢。

最佳答案

查询应该是相反的方式:

SELECT
  fly.codeAirport1,
  a1.value as valueAirport1,
  fly.codeAiport2,
  a2.value as valueAirport2
FROM
  fly
LEFT JOIN
  airports a1 ON a1.code = fly.codeAirport1
LEFT JOIN
  airports a2 ON a2.code = fly.codeAirport2

09-11 02:50