ambiguous column SQL Origin: Data Last updated 12 Oct 2026

Column reference is ambiguous / Column 'id' in field list is ambiguous (MySQL 1052)

A column name exists in more than one joined table, so the database doesn’t know which one you mean.

Exact message you may see is ambiguouscolumn reference is ambiguousambiguous column nameIntegrity constraint violation: 1052
Seen on: MySQL PostgreSQL SQL PHP

Meaning

After a JOIN, unqualified names like id, name or created_at usually exist in several tables. Qualify them with the table name or alias.

Common causes

  • Unqualified column in SELECT/WHERE/ORDER BY after a JOIN
  • Same column name in a subquery and outer query
  • ORM building raw where clauses without table prefixes

⚡ Quick fix

  1. Prefix columns with table aliases (u.id, o.id)
  2. Alias output columns that share names (o.id AS order_id)

Detailed fix by platform

SQL

  1. Qualify every column in joins:
    sql
    SELECT u.id AS user_id, o.id AS order_id, o.total
    FROM users u
    JOIN orders o ON o.user_id = u.id
    WHERE o.status = 'paid'
    ORDER BY o.created_at DESC;

PHP

  1. Laravel: ->where('orders.status', 'paid') instead of ->where('status', 'paid') on joined queries.

How to diagnose

  1. Column — Which column is named?
  2. Tables — Which joined tables contain it?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

102 — SQL Server: Incorrect syntax near 'x'. (Msg 102) (SQL)1021054 — MySQL ERROR 1054 (42S22): Unknown column in 'field list' (MySQL)10541064 — MySQL ERROR 1064 (42000): You have an error in your SQL syntax (MySQL)10641066 — MySQL ERROR 1066 (42000): Not unique table/alias: 'x' (SQL)10661136 — MySQL ERROR 1136 (21S01): Column count doesn't match value count at row 1 (SQL)11361222 — MySQL ERROR 1222 (21000): The used SELECT statements have a different number of columns (SQL)12221248 — MySQL ERROR 1248 (42000): Every derived table must have its own alias (SQL)12481267 — MySQL ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '=' (SQL)1267ambiguous…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.