Skip to content

Column Does Not Exist

Error message

                column does not exist
              

Quick summary

Your query references a column that does not exist in the specified table — it may be misspelled, not yet added, or in a different table.

Why this happens

  • Typo in the column name

  • The column has not been added to the table (missing ALTER TABLE migration)

  • The column exists in a different table than the one queried

  • Case sensitivity mismatch (some databases treat column names as case-sensitive)

Minimal example

✗ Broken code
SELECT fist_name FROM users;
-- Typo: 'fist_name' instead of 'first_name'
✓ Fixed code
SELECT first_name FROM users;

The column fist_name does not exist — fixing the typo to first_name resolves the error.

How to diagnose

  • Check the spelling of the column name

  • Describe the table to see its columns: \d table_name in psql or DESCRIBE table_name in MySQL

  • Verify the column is in the table you are querying, not a related table

  • Check for case sensitivity issues — try quoting the column name

How to fix

  • Fix the typo to match the actual column name

  • Run a migration to add the missing column: ALTER TABLE ... ADD COLUMN ...

  • Reference the column from the correct table (use a JOIN if needed)

  • Quote the column name if case is the issue

How to prevent

  • Use an ORM that validates column names at compile time

  • Keep your schema documented and up to date

  • Use consistent naming conventions (snake_case is common for columns)

Related Resources

Related Glossary

Related Lessons

  • Tables

    Learn about table columns.

← Back to language