MySQL throws ER_NONUNIQ_TABLE (Error 1066) when the same table name or alias appears more than once in a querys FROM or JOIN clause.
MySQL Error 1066: ER_NONUNIQ_TABLE signals duplicate table names or aliases in the FROM clause. Remove the duplicate reference or rename the conflicting alias to fix the issue.
Not unique table/alias: '%s'
Error 1066 occurs when MySQL encounters two identical table names or aliases in a single query block. The parser cannot unambiguously determine which table to reference, so execution stops with ER_NONUNIQ_TABLE.
The error typically appears in SELECT statements that join the same table twice, in subqueries with overlapping aliases, or in UPDATE/DELETE statements using JOIN syntax.
Resolving the conflict immediately restores query execution.
Duplicate table aliases inside the same scope trigger the error first. When two tables share the same alias, MySQL cannot map column references unambiguously.
Using the same physical table twice in the FROM clause without an alias also causes a clash.
MySQL treats the unaliased table name as its own alias, so the second occurrence is not unique.
Identify the duplicated name by looking at the error line. Rename one of the aliases or fully qualify the table with a unique alias. Alternatively, restructure the query with common table expressions (CTEs) to isolate scopes.
After renaming, rerun the query to confirm resolution.
Add the alias change to version control or Galaxys endorsed query library to prevent regressions.
Self-join queries often reuse the same table name. Assign aliases like t1 and t2 to differentiate the two copies. Subqueries that reference the outer querys tables need unique aliases as well.
UPDATE statements with JOIN mistakenly omitting an alias on the target table can collide with the join table.
Always alias both tables clearly.
Adopt a consistent aliasing convention: short prefixes plus numerals (e.g., u1, u2) for multiple uses of the same table. Enforce this rule with code reviews in Galaxy Collections.
Enable MySQLs sql_require_primary_key or use Galaxys linting to highlight duplicate aliases during editing, catching the problem before execution.
Error 1052 (ER_NONUNIQ): column repeats across joined tables.
Prefix columns with their table alias to resolve.
Error 1093 (ER_UPDATE_TABLE_IS_REFERENCED): updating a table that is also read in the same query. Use a derived table or subquery to separate reads and writes.
.
Using the same alias for two joins on the same or different tables makes the alias non-unique.
Repeating a table name in the FROM list without giving each occurrence a unique alias causes a clash.
An inner subquery that assigns an alias already used by the outer query raises ER_NONUNIQ_TABLE.
When the target table is unaliased but also appears as a join participant with an alias, MySQL flags the duplication.
.
It is a compile-time syntax error raised during query parsing, not during execution.
No. The error enforces unambiguous table references. You must change the query to fix it.
Aliases are case-insensitive on default MySQL installations, so User and user are identical and will still clash.
Galaxys real-time linter flags duplicate aliases before execution, and its AI copilot suggests unique names automatically.