1066 SQL Origin: Data Last updated 13 Oct 2026

MySQL ERROR 1066 (42000): Not unique table/alias: 'x'

The same table or alias appears twice in a FROM/JOIN without distinct aliases.

Exact message you may see Not unique table/alias
Seen on: SQL

Meaning

Self-joins and repeated joins need different aliases. ORMs joining the same relation twice can produce this.

Common causes

  • Self-join without aliases
  • Joining the same table twice
  • ORM eager loads duplicating joins

⚡ Quick fix

  1. Give each occurrence its own alias (u1, u2)
  2. Check ORM eager-loading config if the SQL is generated

Detailed fix by platform

SQL

  1. SELECT e.name, m.name AS manager FROM employees e JOIN employees m ON m.id = e.manager_id;

How to diagnose

  1. Alias — Which name repeats?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

🔧 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):

1136 — 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)1267aggregate in WHERE — ERROR: aggregate functions are not allowed in WHERE (use HAVING) / MySQL 1111 Invalid use of group function (SQL)aggregate in WHEREambiguous column — Column reference is ambiguous / Column 'id' in field list is ambiguous (MySQL 1052) (SQL)ambiguous columnGROUP BY — Column must appear in the GROUP BY clause / isn't in GROUP BY (MySQL 1055 only_full_group_by) (SQL)GROUP BYmissing FROM-clause — ERROR: missing FROM-clause entry for table "x" (PostgreSQL)missing FROM-clause1066

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.