1052ERRORTier 1 — Safe✅ HIGH confidenceColumn in field list is ambiguous
What this means
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.
Why it happens
- 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
How to reproduce
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 tablesFix 1: Qualify every ambiguous column with a table alias
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.
What not to do
Use SELECT * in multi-table JOINs
Why it's wrong: Returns duplicate column names and masks ambiguity errors until they surface as bugs.
Sources
📚 Official docs: https://mariadb.com/kb/en/join-syntax/
🔧 Source ref: MariaDB Server error code 1052 / ER_NON_UNIQ_ERROR
📖 Further reading: MariaDB JOIN Syntax
Confidence assessment
✅ HIGH confidence
Stable.
See also
🔗 Related errors
📄 Reference pages