MySQL ERROR 1222 (21000): The used SELECT statements have a different number of columns
The SELECTs combined with UNION return different numbers of columns.
Seen on:
SQL
Meaning
Each SELECT in a UNION must return the same number of columns with compatible types, in the same order.
Common causes
- Different column counts in UNION parts
- SELECT * on tables with different columns
⚡ Quick fix
- List columns explicitly in each SELECT
- Pad with NULL AS col where a part lacks a column
Detailed fix by platform
SQL
SELECT id, email, NULL AS phone FROM users UNION ALL SELECT id, email, phone FROM leads;
How to diagnose
- Counts — Columns per SELECT?
- Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.
🧠 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