mysqldude
Error codes › 1054

MySQL & MariaDB error 1054: Unknown column

Error messageUnknown column '…' in '…'
Example from our test runs: Unknown column 'SQL_CACHE' in 'field list' (8.0.46)

The statement refers to a column the server can't find in the tables it is reading. Often a typo, a column alias used too early, or a quoted string the server reads as a column name.

MySQLMariaDB
SymbolER_BAD_FIELD_ERRORER_BAD_FIELD_ERROR
SQLSTATE42S2242S22
TypeServer errorServer error
Versionsevery release since 5.0 activeevery release since 5.5 active

What it means

The message names the column and the part of the statement it appeared in: Unknown column 'full_name' in 'field list', … in 'where clause', … in 'on clause'. The second part is the quickest clue to where to look.

Why it happens

  • A typo, or the column was renamed or dropped.
  • An alias used in WHERE: SELECT price * qty AS total … WHERE total > 100. WHERE is evaluated before the SELECT list, so the alias doesn’t exist yet. (HAVING and ORDER BY can use it.)
  • Double quotes: with ANSI_QUOTES in sql_mode (and in some tools), "Ann" means an identifier, not a string, so WHERE name = "Ann" looks for a column called Ann. Use single quotes for strings.
  • In a JOIN with USING or a comma join mixed with JOIN, a table isn’t visible in the ON clause where you reference it.
  • In a trigger, NEW.col or OLD.col names a column the table doesn’t have. Our tests found exactly this bug in an old audit-trigger guide.
  • SELECT … SQL_CACHE on MySQL 8.0 also gives 1054, because the query cache keywords were removed.

How to fix it

  • DESCRIBE tablename; and compare the spelling and case.
  • Repeat the expression instead of the alias in WHERE, or move the condition to HAVING, or wrap the query in a derived table.
  • Use single quotes for string values, backticks for identifiers.

Reproduce it yourself

These steps are the exact test our harness runs. Use a scratch server, never production.

  1. Connect with mysql -u root -p and create a scratch database and the test data:

    CREATE DATABASE demo;
    USE demo;
    CREATE TABLE emp (id INT, name VARCHAR(20));
  2. Run:

    SELECT id, full_name FROM emp;

You get: Unknown column 'full_name' in 'SELECT'(11.8.9)

Verified fixes

  1. Repeat the expression in WHERE (or use HAVING / a derived table)

    SELECT id * 2 AS dbl FROM emp WHERE id * 2 > 2;

Tested on

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
Reference a column the table doesn't have
repro
✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054
A string in double quotes under ANSI_QUOTES is read as a column name
version check
✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054
A SELECT alias used in WHERE
version check
✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054✓ 1054
Repeat the expression in WHERE (or use HAVING / a derived table)
fix
✓✓✓✓✓✓✓✓✓
Reference a column the table doesn't have repro
MySQL 5.6✓ 10545.7✓ 10548.0✓ 10548.4✓ 10549✓ 1054
MariaDB 10.6✓ 105410.11✓ 105411.4✓ 105411.8✓ 1054
A string in double quotes under ANSI_QUOTES is read as a column name version check
MySQL 5.6✓ 10545.7✓ 10548.0✓ 10548.4✓ 10549✓ 1054
MariaDB 10.6✓ 105410.11✓ 105411.4✓ 105411.8✓ 1054
A SELECT alias used in WHERE version check
MySQL 5.6✓ 10545.7✓ 10548.0✓ 10548.4✓ 10549✓ 1054
MariaDB 10.6✓ 105410.11✓ 105411.4✓ 105411.8✓ 1054
Repeat the expression in WHERE (or use HAVING / a derived table) fix
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9

Related errors

  • 1064 ER_PARSE_ERRORexplained
  • 1146 ER_NO_SUCH_TABLEexplained
  • 1052 ER_NON_UNIQ_ERROR

Where this error shows up in our guides

  • Query_cache_type · SELECT SQL_CACHE ... (original) MySQL 8.0 8.4 9
  • Resetting lost root password · --skip-grant-tables + UPDATE mysql.user SET password=PASSWORD() (pre-5.7 recipe) MySQL 5.7
  • Runtime values · Post's trigger (NEW.WITHDRAWL typo) then INSERT MySQL 5.6 5.7 8.0 8.4 9MariaDB 10.6 10.11 11.4 11.8
  • Triggers for auditing · Post's audit table + triggers, then INSERT (original as published) MySQL 5.6 5.7 8.0 8.4 9MariaDB 10.6 10.11 11.4 11.8
  • Triggers for auditing · Post's UPDATE trigger references NEW.QUANTITY (not in table) MySQL 5.6 5.7 8.0 8.4 9MariaDB 10.6 10.11 11.4 11.8