如何克服连接联合表与其他表的错误

时间:2015-07-26 12:07:29

标签: google-bigquery

虽然我们尝试将一方的联合表与另一方的其他表联系起来,

SELECT A.x,B.y FROM ([DataSet.Liad],[DataSet.Livne]) AS A INNER JOIN [DataSet.Names] AS B ON A.ID = B.ID LIMIT 10

我们收到此错误:

  

错误:2.1 - 0.0:JOIN不能直接应用于表联合或表通配符函数。考虑将表联合或表通配符函数包装在子查询中(例如,SELECT *)。

为了解决这个错误,我建议你使用View。 将此查询的union保存为View,DataSet.LiadLivne:

SELECT * FROM [DataSet.Liad],[DataSet.Livne] 

使用视图执行原点查询:

SELECT A.x,B.y FROM [DataSet.LiadLivne] AS A INNER JOIN [DataSet.Names] AS B ON A.ID = B.ID LIMIT 10

享受

1 个答案:

答案 0 :(得分:4)

你需要写为:

SELECT A.x,
       B.y
FROM
  (SELECT A.x
   FROM ([DataSet.Liad],[DataSet.Livne])) AS A
INNER JOIN [DataSet.Names] AS B ON A.ID = B.ID LIMIT 10