Column in field list is ambiguous
Error 1052 (SQLSTATE 23000) is raised when a column name referenced in a SELECT, WHERE, or ORDER BY clause exists in more than one table involved in a JOIN and is not qualified with a table alias or table name.
- 1Two or more joined tables share a column name (e.g. both have an id or name column)
- 2Column reference is unqualified — no table prefix or alias
A SELECT with a JOIN where the column name appears in multiple tables.
SELECT id, name FROM orders JOIN customers ON orders.customer_id = customers.id; -- 'id' and 'name' exist in both tables
expected output
ERROR 1052 (23000): Column 'id' in field list is ambiguous
Fix
Qualify every ambiguous column with a table alias
WHEN Always — qualify columns in multi-table queries.
SELECT o.id AS order_id, c.id AS customer_id, c.name FROM orders o JOIN customers c ON o.customer_id = c.id;
Why this works
Prefixing columns with a table alias removes ambiguity. Assigning aliases to result columns also prevents confusion in application code.
✕ Use SELECT * in multi-table JOINs
Returns duplicate column names and masks ambiguity errors until they surface as bugs.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev