Unknown column in field list
Error 1054 (SQLSTATE 42S22) is returned when a query references a column name that does not exist in the specified table or is ambiguous in the FROM clause. This is a compile-time error — the query is rejected before execution.
- 1Column name typo in SELECT, WHERE, or ORDER BY
- 2Referencing a column that was renamed in a schema migration
- 3Using a column alias in a WHERE clause (not allowed — aliases are resolved after WHERE)
- 4Ambiguous column name when the same column name exists in multiple joined tables
A SELECT references a column that does not exist.
CREATE TABLE users (id INT, email VARCHAR(255)); SELECT user_name FROM users; -- column is 'email', not 'user_name'
expected output
ERROR 1054 (42S22): Unknown column 'user_name' in 'field list'
Fix 1
Check the actual column names with DESCRIBE
WHEN When unsure of the exact column names.
DESCRIBE users; -- or: SHOW COLUMNS FROM users;
Why this works
DESCRIBE returns the column name, type, nullability, key, default value, and extra attributes for each column in the table, giving the exact names to use in queries.
Fix 2
Qualify ambiguous column names with the table name
WHEN When the same column name exists in multiple joined tables.
SELECT users.id, orders.id AS order_id FROM users JOIN orders ON users.id = orders.user_id;
Why this works
Using table.column notation eliminates ambiguity. The parser can then resolve each column reference to its specific table.
✕ Use SELECT * to avoid specifying column names
While SELECT * avoids 1054, it returns all columns including ones the application does not need, and will silently change shape if columns are added or removed.
Stable error code.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev