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
- Check information_schema before adding
- Alias duplicate columns in joins
- Make migrations idempotent
Detailed fix by platform
MySQL
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
- Statement — ALTER or SELECT?
- 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026