- Error number
- 1054
- SQLSTATE
42S22- Symbol
ER_BAD_FIELD_ERROR- Product
- MySQL Server
- Versions
- All MySQL versions (checked on MySQL 8.0.46)
- Category
- Syntax & Names
- Last reviewed
- 24 October 2026
On this page
What it means
Error 1054 means the query refers to a column name that MySQL cannot find in any table (or alias) that is visible at that point of the query.
MySQL resolves every column name against the tables in the FROM clause, and the message tells you both the name it could not resolve and where it found it. 'field list' is the SELECT list (and also the column list of INSERT and the SET list of UPDATE); the others are 'where clause', 'on clause', 'group statement', 'having clause' and 'order clause'. Searching your statement for the quoted name in that clause takes you straight to the problem.
The column does not have to be misspelt to be unknown. A SELECT alias does not exist yet when WHERE is evaluated, a table alias hides the original table name (after FROM customers AS c you must write c.name, not customers.name), and a value wrapped in backticks is read as a column name. If the whole table is missing you get 1146 instead.
Common causes
- A typo, or a column that was renamed or dropped by a migration while the application code still uses the old name.
- Using a SELECT alias in WHERE. Standard SQL does not allow it because WHERE runs before the select list is computed; aliases are allowed in GROUP BY, HAVING and ORDER BY.
- Qualifying with the wrong name: the table name after it has been given an alias, or the alias of a different table in a JOIN (
o.customerwhen the column iso.customer_id). - A string value written in backticks (
`Sara`) instead of single quotes, so MySQL looks for a column called Sara. Double quotes are a string in the default sql_mode but become identifiers when ANSI_QUOTES is enabled. - Referring to a column of a table that is not in the FROM clause of that query block, for example an outer column misspelt inside a correlated subquery, or a HAVING condition on a column that is neither grouped nor selected.
Diagnose it
Read-only These statements only read metadata (information_schema, performance_schema and SHOW statements) or your own data. They do not change data, privileges or configuration, so they are safe to run first.
List the real column names of the table
SELECT column_name, data_type, ordinal_position
FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'customers'
ORDER BY ordinal_position; The exact names to use. Compare them with the name in the error; a near match (name for nme, customer_id for customer) is the fix.
Find which table has a column with that name
Useful in a JOIN, or when the column was moved to another table.
SELECT table_name, column_name
FROM information_schema.columns
WHERE table_schema = DATABASE()
AND column_name LIKE '%customer%'
ORDER BY table_name; Every table in the current database with a matching column. Qualify the column with the alias of that table in your query.
Show the table definition as MySQL sees it
SHOW CREATE TABLE customers; The current definition, including columns added or renamed by recent migrations. If the column is missing here, the migration that adds it has not run on this database.
How to fix it
Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.
Use the correct column name
Client or network sideCopy the name from the column list above. Qualifying every column with its table alias in multi-table queries makes this kind of mistake easier to spot and prevents ambiguous column errors (1052) later.
SELECT c.id, c.name
FROM customers AS c
WHERE c.city = 'Leeds';
Repeat the expression in WHERE, or filter in an outer query
Client or network sideA SELECT alias cannot be used in WHERE. Repeat the expression, or compute it in a derived table and filter outside. HAVING also accepts the alias, but HAVING is meant for conditions on groups and filters later, so prefer WHERE for row filters.
SELECT id, total * 1.2 AS gross
FROM orders
WHERE total * 1.2 > 30;
-- or
SELECT id, gross
FROM (SELECT id, total * 1.2 AS gross FROM orders) AS t
WHERE gross > 30;
Quote values with single quotes, names with backticks
Client or network sideSingle quotes make a string value; backticks make an identifier. Use single quotes for values even though double quotes also work in the default sql_mode, because double quotes turn into identifiers when ANSI_QUOTES is on. In application code, pass values as bound parameters instead of building them into the SQL text.
SELECT * FROM customers WHERE name = 'Sara';
Add the column if the application really needs it
Changes schemaWhen the code is right and the database is behind (a migration was not run), run the migration that adds the column rather than editing the table by hand, so every environment stays in step.
Caution: ALTER TABLE on a large table can take time and, depending on the change, block writes. Test it on a copy of production data and run it in a maintenance window if needed.
ALTER TABLE customers ADD COLUMN created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;
Examples
A misspelt column in the SELECT list
CREATE TABLE customers (
id INT PRIMARY KEY,
name VARCHAR(100),
city VARCHAR(50)
);
SELECT id, nme FROM customers;
ERROR 1054 (42S22): Unknown column 'nme' in 'field list'
Reproduced on MySQL 8.0.46, 24 October 2026.
Using a SELECT alias in WHERE
CREATE TABLE orders (id INT PRIMARY KEY, customer_id INT, total DECIMAL(10,2));
SELECT id, total * 1.2 AS gross
FROM orders
WHERE gross > 30;
ERROR 1054 (42S22): Unknown column 'gross' in 'where clause'
Reproduced on MySQL 8.0.46, 24 October 2026.
A value in backticks instead of quotes
CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(100));
SELECT * FROM customers WHERE name = `Sara`;
ERROR 1054 (42S22): Unknown column 'Sara' in 'where clause'
Reproduced on MySQL 8.0.46, 24 October 2026.
The wrong column name in a JOIN condition
CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(100));
CREATE TABLE orders (id INT PRIMARY KEY, customer_id INT, total DECIMAL(10,2));
SELECT c.name, o.total
FROM customers AS c
JOIN orders AS o ON o.customer = c.id;
ERROR 1054 (42S22): Unknown column 'o.customer' in 'on clause'
Reproduced on MySQL 8.0.46, 24 October 2026.
How to prevent it
Give every table an alias in multi-table queries and qualify every column with it, and let a schema-aware editor or IDE autocomplete column names. Keep migrations and application code in the same release so a renamed column never reaches one without the other.
Remember the order MySQL evaluates a query in: FROM and JOIN, then WHERE, then GROUP BY and HAVING, then the SELECT list, then ORDER BY. A name is only visible to the clauses that run after it is defined.
Common questions
How do I fix "Unknown column in field list"?
The quoted name is not a column of any table in your FROM clause. Check the spelling against SHOW CREATE TABLE or information_schema.columns, check that it is qualified with the right alias, and for INSERT check the column list in brackets after the table name.
Why can I not use a column alias in WHERE?
WHERE is evaluated before the SELECT list, so the alias does not exist yet. Repeat the expression in WHERE, or wrap the query in a derived table and filter on the alias outside it. ORDER BY, GROUP BY and HAVING can use the alias.
Why does MySQL say Unknown column when I compare with a text value?
The value is probably in backticks, which MySQL reads as a column name. Use single quotes for string values: WHERE name = 'Sara'. Double quotes also cause this if the ANSI_QUOTES sql_mode is enabled.
What does 'on clause' or 'order clause' in the message mean?
It tells you which part of the statement contains the unknown name: on clause is a JOIN ... ON condition, order clause is ORDER BY, group statement is GROUP BY and field list is the SELECT, INSERT column or UPDATE SET list.
Learn more on CodeWithSQL
Official documentation
- Problems with column aliases
- Schema object names (identifier quoting)
- The INFORMATION_SCHEMA COLUMNS table
- MySQL 8.0 server error message reference
Last technically reviewed 24 October 2026; examples and diagnostics run on MySQL 8.0.46. Message templates checked against the server's error catalogue (perror) for that version.