1054
MySQLERRORCommonSchemaHIGH confidence

Unknown column in field list

What this means

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.

Why it happens
  1. 1Column name typo in SELECT, WHERE, or ORDER BY
  2. 2Referencing a column that was renamed in a schema migration
  3. 3Using a column alias in a WHERE clause (not allowed — aliases are resolved after WHERE)
  4. 4Ambiguous column name when the same column name exists in multiple joined tables
How to reproduce

A SELECT references a column that does not exist.

trigger — this will error
trigger — this will error
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.

Check the actual column names with DESCRIBE
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.

Qualify ambiguous column names with the table name
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.

What not to do

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.

Version notes
All versions

Stable error code.

Sources
Official documentation ↗

MariaDB Server error code 1054 / ER_BAD_FIELD_ERROR

MariaDB DESCRIBE

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors