Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

The column named in the statement is not found in that table (error 1054)

ErrorERROR 1054 (42S22): Unknown column 'Maaz' in 'field list'

Short answer

Error 1054 means the server read a word as a column name and found no such column in that place. The second part of the message says where: field list, where clause, on clause. Usual causes are a text value without quotes, a name that differs from the table, or double quotes read as identifiers under ANSI_QUOTES.

  • Applies to MariaDB 11.4 LTS, MySQL 8.4 LTS, mariadb client 11.4
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List the real column names of the table named in the statement and compare them with the name in the error.

    SHOW COLUMNS FROM customers;
  2. 2Match what you see, then jump to its fix

    1. 1The unknown 'column' is actually a value from your data, in 'field list'A text value is written without quotesFix
    2. 2Values in double quotes fail on one server but worked on anotherDouble quotes are read as identifiers (ANSI_QUOTES)Fix
    3. 3The name in the error is a column you expected to exist, in 'where clause' or 'field list'The column name differs from the table definitionFix

What does the error look like?

  • ERROR 1054 (42S22): Unknown column 'Maaz' in 'field list'
  • ERROR 1054 (42S22): Unknown column 'email' in 'where clause'
  • SQLSTATE[42S22]: Column not found: 1054 Unknown column

Cause 1 of 3

A text value is written without quotes

1Check

In an INSERT, a word without quotes is read as a column name. The word in the error is the value you meant.

INSERT INTO customers (name, city) VALUES (Maaz, Leeds);

2Fix

Put string and date values in single quotes. Numbers stay bare.

INSERT INTO customers (name, city) VALUES ('Maaz', 'Leeds');

3Verify

The row is inserted.

SELECT name, city FROM customers ORDER BY id DESC LIMIT 1;

Confirmed by mariadb.com

Did this fix it?

Cause 2 of 3

Double quotes are read as identifiers (ANSI_QUOTES)

1Check

With the ANSI_QUOTES SQL mode, double quotes mark identifiers, not strings, so a quoted value becomes a column name.

SELECT @@sql_mode;

2Fix

Use single quotes for values. They are strings in every mode.

SELECT * FROM customers WHERE city = 'Leeds';

3Verify

The query returns rows instead of the error.

SELECT @@sql_mode;

Confirmed by mariadb.com

Did this fix it?

Cause 3 of 3

The column name differs from the table definition

1Check

Compare spelling, underscores and plural forms with SHOW COLUMNS. A column added in a migration that has not run on this server gives the same error.

SHOW COLUMNS FROM customers;

2Fix

Use the exact name from the table, quoted with backticks if it holds special characters. Run the missing migration if the column should exist.

SELECT `full_name` FROM customers;

3Verify

The statement runs and returns the column.

SHOW COLUMNS FROM customers LIKE 'full_name';

Confirmed by mariadb.com

Did this fix it?

How do I stop it coming back?

  • Build SQL with parameters or prepared statements so values are never typed as bare words.
  • Keep the sql_mode the same on every environment.
  • Run migrations in order and check the schema version before deploying code that uses a new column.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.