Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-29 · container image mysql:8.4
The message names the column and the part of the query where it was used: 'field list' is the SELECT list (or the INSERT column list), 'where clause' is WHERE, 'on clause' is a JOIN condition. That second part narrows down the cause quickly.
The "column" is not always a column you meant to write. An unquoted string value, or an alias defined in the SELECT list, is also looked up as a column name.
01The column name is misspelled
The table has user_name, but the query asks for username. SHOW COLUMNS FROM users lists the real column names.
Setup
CREATE TABLE users (id INT PRIMARY KEY, user_name VARCHAR(50), email VARCHAR(100));
INSERT INTO users VALUES (1, 'Kim', 'kim@example.com');Query OK, 0 rows affected (0.01 sec)
Query OK, 1 row affected (0.00 sec)SELECT id, username FROM users;ERROR 1054 (42S22): Unknown column 'username' in 'field list'SHOW COLUMNS FROM users;+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| id | int | NO | PRI | NULL | |
| user_name | varchar(50) | YES | | NULL | |
| email | varchar(100) | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)Use the name exactly as SHOW COLUMNS shows it. Column names are not case-sensitive in MySQL, so the problem is the spelling, not the case.
SELECT id, user_name FROM users;+----+-----------+
| id | user_name |
+----+-----------+
| 1 | Kim |
+----+-----------+
1 row in set (0.00 sec)02A string value without quotes in WHERE
WHERE user_name = Kim has no quotes, so MySQL reads Kim as a column name and reports Unknown column 'Kim' in 'where clause'. This often happens when SQL is built by concatenating a variable into the string.
Setup
CREATE TABLE users (id INT PRIMARY KEY, user_name VARCHAR(50));
INSERT INTO users VALUES (1, 'Kim'), (2, 'Lee');Query OK, 0 rows affected (0.01 sec)
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0SELECT id, user_name FROM users WHERE user_name = Kim;ERROR 1054 (42S22): Unknown column 'Kim' in 'where clause'SELECT 'Kim' AS quoted_value;+--------------+
| quoted_value |
+--------------+
| Kim |
+--------------+
1 row in set (0.00 sec)Put string values in single quotes ('Kim'). In application code, use placeholders (prepared statements) instead of concatenating values; the driver then handles quoting.
SELECT id, user_name FROM users WHERE user_name = 'Kim';+----+-----------+
| id | user_name |
+----+-----------+
| 1 | Kim |
+----+-----------+
1 row in set (0.00 sec)03Using a SELECT alias in WHERE
total is an alias created in the SELECT list. WHERE is evaluated before the SELECT list, so the alias does not exist yet and MySQL reports Unknown column 'total' in 'where clause'.
Setup
CREATE TABLE order_lines (id INT PRIMARY KEY, price DECIMAL(10,2), qty INT);
INSERT INTO order_lines VALUES (1, 30.00, 2), (2, 50.00, 3), (3, 10.00, 1);Query OK, 0 rows affected (0.01 sec)
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0SELECT id, price * qty AS total FROM order_lines WHERE total > 50;ERROR 1054 (42S22): Unknown column 'total' in 'where clause'SELECT id, price * qty AS total FROM order_lines;+----+--------+
| id | total |
+----+--------+
| 1 | 60.00 |
| 2 | 150.00 |
| 3 | 10.00 |
+----+--------+
3 rows in set (0.00 sec)Repeat the expression in WHERE (price * qty > 50). This returned ids 1 and 2.
SELECT id, price * qty AS total FROM order_lines WHERE price * qty > 50;+----+--------+
| id | total |
+----+--------+
| 1 | 60.00 |
| 2 | 150.00 |
+----+--------+
2 rows in set (0.00 sec)04Mixing comma joins with JOIN … ON
In FROM customers c, orders o JOIN items i ON …, JOIN binds tighter than the comma. The ON clause belongs to orders o JOIN items i only, so c.id is not visible there and MySQL reports Unknown column 'c.id' in 'on clause'. This is a classic error in queries written for older MySQL versions.
Setup
CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(50));
CREATE TABLE orders (id INT PRIMARY KEY, customer_id INT, item_id INT);
CREATE TABLE items (id INT PRIMARY KEY, title VARCHAR(50));
INSERT INTO customers VALUES (1, 'Kim');
INSERT INTO items VALUES (10, 'pen');
INSERT INTO orders VALUES (100, 1, 10);Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.01 sec)
Query OK, 1 row affected (0.00 sec)SELECT c.name, i.title
FROM customers c, orders o
JOIN items i ON i.id = o.item_id AND o.customer_id = c.id;ERROR 1054 (42S22): Unknown column 'c.id' in 'on clause'SELECT c.name, o.id AS order_id FROM customers c, orders o WHERE o.customer_id = c.id;+------+----------+
| name | order_id |
+------+----------+
| Kim | 100 |
+------+----------+
1 row in set (0.00 sec)Write every join as an explicit JOIN … ON. The rewritten query returned Kim and pen.
SELECT c.name, i.title
FROM customers c
JOIN orders o ON o.customer_id = c.id
JOIN items i ON i.id = o.item_id;+------+-------+
| name | title |
+------+-------+
| Kim | pen |
+------+-------+
1 row in set (0.00 sec)FAQ
How do I fix MySQL error 1054 Unknown column in 'field list'?
Compare the column name in the message with SHOW COLUMNS FROM table. In an INSERT, the same message appears when the column list has a name the table does not have.
Why does MySQL say Unknown column for a string value?
The value has no quotes, so it is read as a column name. Write 'Kim' with single quotes, or use placeholders in your application code.
Can I use a column alias in WHERE in MySQL?
No. WHERE is evaluated before the SELECT list, so the alias is unknown there. Repeat the expression in WHERE.
What does Unknown column in 'on clause' mean?
The column belongs to a table that is not visible in that ON clause, most often because comma joins and JOIN … ON are mixed. Rewrite every join as an explicit JOIN.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13