1060 🐬 MySQL

MySQL ERROR 1060 (42S21): Duplicate column name 'x'

A CREATE/ALTER adds a column that already exists, or a SELECT in a view/derived table produces two columns with the same name.

Seen on: MySQL

Meaning

Re-running migrations, or joins producing duplicate column names inside CREATE VIEW/derived tables.

Common causes

  • Migration adding an existing column
  • SELECT * from a join inside a view/CTAS
  • Duplicate aliases

⚡ Quick fix

  1. Check information_schema before adding
  2. Alias duplicate columns in joins
  3. Make migrations idempotent

Detailed fix by platform

MySQL

  1. SELECT u.id AS user_id, o.id AS order_id FROM users u JOIN orders o ON o.user_id = u.id;

How to diagnose

  1. Statement — ALTER or SELECT?
  2. Column — Which name?

🧠 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.