【问题标题】:SQL Syntax JOIN google bigquerySQL 语法 JOIN google bigquery
【发布时间】:2012-07-28 12:32:18
【问题描述】:

我在 Google BigQuery 中收到此错误:

Error: Ambiguous field reference in SELECT clause. (Remember to fully qualify all field names in the SELECT clause as <table.field>.)

我的查询是

SELECT LoanPerf1.loankey, Loans.Key
FROM   prosperloans1.LoanPerf1
JOIN   prosperloans1.Loans
       ON LoanPerf1.loankey = Loans.Key

prosperloans1 是数据集 ID 2个表名是正确的。 无论哪个字段名首先出现在 select 子句中,都会返回错误。

Google SQL Syntax 上的文档说这是正确的:

// Simple JOIN of two tables
SELECT table1.id, table2.username
FROM   table1
JOIN   table2
       ON table1.name = table2.name AND table1.id = table2.customer_id;

谢谢 肖恩

【问题讨论】:

    标签: google-bigquery


    【解决方案1】:

    尝试在表名中添加 AS 子句:

    SELECT LoanPerf1.loankey, Loans.Key FROM prosperloans1.LoanPerf1 as LoanPerf1 JOIN prosperloans1.Loans as Loans ON LoanPerf1.loankey = Loans.Key

    【讨论】:

    • 我发现这行得通:SELECT perf.status, loan.loankey FROM prosperloans1.LoanPerf1 AS perf JOIN prosperloans1.loansfinalstatus2 AS loan ON perf.loankey = loan.loankey;所以它要么是您提到的 AS,要么是 ON 语句中的字段具有匹配的字段名称。
    猜你喜欢
    • 2023-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-29
    • 2015-05-27
    • 1970-01-01
    • 1970-01-01
    • 2013-06-07
    相关资源
    最近更新 更多