BigQuery error · Query and syntax errors
Column name is ambiguous
The query reads two or more tables, subqueries or UNNEST results that all have a column with this name, and the reference doesn't say which one. Qualify the column with its table alias, join with USING, or rename one side.
The error message
Column name <column> is ambiguous at [<line>:<column>]
Causes
The same column on both sides of a join
Joining orders and customers on customer_id and then selecting plain customer_id fails: Column name customer_id is ambiguous. Columns such as id, created_at, updated_at and date exist in most tables and are the usual suspects.
UNNEST of a field with a common name
Unnesting an array of structs whose fields share a name with a column of the table, or unnesting two arrays with the same field names, makes those names ambiguous.
SELECT * from a join used in a later step
A CTE built with SELECT * from a join carries both copies of the shared column, and a later reference to it fails.
How to fix it
1. Qualify the column with a table alias
Give every table a short alias and prefix shared columns with it.
WITH orders AS (SELECT 1 AS customer_id, 5 AS amount),
customers AS (SELECT 1 AS customer_id, 'Ann' AS name)
SELECT o.customer_id, c.name, o.amount
FROM orders AS o
JOIN customers AS c
ON o.customer_id = c.customer_id;2. Join with USING
With USING (customer_id) the join key appears once in the result and can be referenced without a prefix.
WITH orders AS (SELECT 1 AS customer_id, 5 AS amount),
customers AS (SELECT 1 AS customer_id, 'Ann' AS name)
SELECT customer_id, name, amount
FROM orders
JOIN customers USING (customer_id);3. Rename columns before they meet
Use SELECT * EXCEPT (...) or explicit aliases in a CTE so each name is unique after the join.
WITH orders AS (SELECT 1 AS customer_id, TIMESTAMP '2026-11-22 10:00:00 UTC' AS created_at),
customers AS (SELECT 1 AS customer_id, TIMESTAMP '2026-01-05 09:00:00 UTC' AS created_at)
SELECT o.customer_id, o.created_at AS order_created_at, c.created_at AS customer_created_at
FROM orders AS o
JOIN customers AS c USING (customer_id);How to prevent it
- Alias every table in multi-table queries and qualify every column, even when it isn't ambiguous yet: adding a column to a joined table later can break unqualified queries.
- Prefer explicit column lists over
SELECT *in CTEs and views built on joins.
FAQ
Is a query with an ambiguous column billed?
No. It fails during analysis, before data is read, so nothing is billed on-demand and no slot time is used under editions.
Why did a query that used to work start failing with this error?
A column with the same name was added to one of the joined tables, for example by a schema change upstream. Qualified column references are immune to this.
Can I SELECT * from a join with duplicate column names?
Yes, the final SELECT * returns both columns. The error appears only when you reference the duplicated name without a qualifier, for example in a later CTE or in WHERE.
Related
SQL reference
More query and syntax errors
All BigQuery error messages · What 50M daily events say about BigQuery failures
