How to fix ERROR 1054: Unknown column in MySQL

MySQLBEGINNERMEDIUMUpdated Sep 14, 2026· 803 views

ERROR 1054 occurs when MySQL cannot find a column you referenced in your query. This is usually caused by a typo, missing quotes around string values, or referencing a column that does not exist in the table.

Quick fix

Fixes 1054

DESCRIBE your_table_name;
-- or
SHOW COLUMNS FROM your_table_name;
  1. Check if the column exists in the table
  2. Check for typos in the column name
  3. Add quotes around string values
  4. Use backticks for reserved keywords and special names
mysql — error
DESCRIBE your_table_name;
-- or
SHOW COLUMNS FROM your_table_name;
ERROR 1054: Unknown column

What this error means

MySQL error 1054 with SQLSTATE code 42S22 means the database engine cannot find the column name you specified in your SQL statement. This error can occur in SELECT, INSERT, UPDATE, DELETE, or ALTER TABLE statements. When MySQL encounters a column reference it cannot match to an actual column in the specified table, it raises this error to prevent execution of the malformed query.

Typical symptoms

  • Query execution fails immediately with "ERROR 1054" message
  • Application crashes or shows a database error when attempting a query
  • String values in INSERT statements are being rejected as column names
  • JOIN or UNION queries fail with unknown column in ON or ORDER BY clauses
  • Code that worked previously suddenly fails after schema changes

Common causes

  1. Column name is misspelled or uses different capitalization than defined in the table
  2. String value in INSERT/UPDATE statement is missing quotes (MySQL interprets it as a column name)
  3. Column does not exist in the table (was never created or was deleted)
  4. Referencing column by original name instead of alias in WHERE clause or when using UNION
  5. Using wrong table name or connected to wrong database schema
  6. Unicode or invisible characters in column name that looks correct but is actually different
  7. Reserved MySQL keyword used as column name without backtick escaping

How to fix "ERROR 1054: Unknown column"

1Check if the column exists in the table

First, verify that the column you are referencing actually exists in the table. Use the DESCRIBE or SHOW COLUMNS command:

sql
DESCRIBE your_table_name;
-- or
SHOW COLUMNS FROM your_table_name;

Look for your column name in the output. If it's not there, the column needs to be created with an ALTER TABLE statement or you're querying the wrong table.

2Check for typos in the column name

Compare the column name in your SQL query with the output from DESCRIBE. Column names are case-sensitive in some MySQL configurations (especially on Linux). Make sure the capitalization matches exactly:

sql
-- If your table has column: user_id
-- This will fail:
SELECT userid FROM users;  -- ERROR 1054

-- This will work:
SELECT user_id FROM users;  -- OK
3Add quotes around string values

If you're inserting or comparing data, make sure string values are wrapped in single quotes. Unquoted values are interpreted as column names:

sql
-- Wrong - MySQL thinks 'John' is a column:
INSERT INTO users (name, email) VALUES (John, john@example.com);
-- ERROR 1054: Unknown column 'John' in 'field list'

-- Correct - values are properly quoted:
INSERT INTO users (name, email) VALUES ('John', 'john@example.com');

-- Wrong in WHERE clause:
SELECT * FROM users WHERE name = John;

-- Correct in WHERE clause:
SELECT * FROM users WHERE name = 'John';
4Use backticks for reserved keywords and special names

If your column name is a MySQL reserved keyword (like order, group, select, etc.), wrap it in backticks:

sql
-- Wrong - MySQL keyword without escaping:
SELECT order, group FROM my_table;
-- ERROR 1054 or syntax error

-- Correct - keywords escaped with backticks:
SELECT `order`, `group` FROM my_table;
5Fix alias references in JOIN and UNION queries

When using JOINs or UNION clauses, you must reference aliases correctly:

For UNION with ORDER BY:

sql
-- Wrong - referencing original column name:
SELECT id AS user_id, name FROM users
UNION
SELECT id, name FROM customers
ORDER BY id;  -- ERROR 1054: Unknown column 'id'

-- Correct - using the alias from first SELECT:
SELECT id AS user_id, name FROM users
UNION
SELECT id, name FROM customers
ORDER BY user_id;

For JOIN with ON clause:

sql
-- Wrong - using alias before it's available:
SELECT u.* FROM users AS u
JOIN posts AS p ON u.id = user_id;  -- ERROR 1054

-- Correct - using full table reference:
SELECT u.* FROM users AS u
JOIN posts AS p ON u.id = p.user_id;
6Verify the correct database is selected

Make sure your application is connected to the correct database schema. Different databases may have different table structures:

sql
-- Check current database:
SELECT DATABASE();

-- Switch to correct database:
USE correct_database_name;
7Check for hidden characters or encoding issues

In rare cases, column names can contain invisible Unicode characters or have different encodings. If the column looks correct but still fails:

sql
-- Copy-paste the exact column name from DESCRIBE output
-- Or view raw bytes if needed (for hex values):
SHOW CREATE TABLE your_table_name\G

-- Recreate the column if it has encoding issues
ALTER TABLE your_table_name 
CHANGE COLUMN `old_name` `new_name` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Advanced notes

ERROR 1054 can sometimes be caused by triggers or stored procedures with syntax errors that reference non-existent columns. If you're seeing this error after recent schema changes, check your triggers and procedures with SHOW CREATE TRIGGER and SHOW CREATE PROCEDURE. On some systems, MySQL table and column names are case-sensitive (Linux) while on others they are not (Windows/Mac). This can cause issues when migrating databases between systems. Always use lowercase or consistent casing in your schema. When using ORMs like Sequelize, Eloquent, or Doctrine, similar errors usually indicate model-to-database schema mismatch—verify your model definitions match the actual table structure.

Frequently asked questions

What does "1054" mean?
MySQL error 1054 with SQLSTATE code 42S22 means the database engine cannot find the column name you specified in your SQL statement. This error can occur in SELECT, INSERT, UPDATE, DELETE, or ALTER TABLE statements. When MySQL encounters a column reference it cannot match to an actual column in the specified table, it raises this error to prevent execution of the malformed query.
How do I fix "1054"?
ERROR 1054 occurs when MySQL cannot find a column you referenced in your query. This is usually caused by a typo, missing quotes around string values, or referencing a column that does not exist in the table.
What causes "1054"?
Column name is misspelled or uses different capitalization than defined in the table String value in INSERT/UPDATE statement is missing quotes (MySQL interprets it as a column name) Column does not exist in the table (was never created or was deleted)
Is the "1054" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading