Column Does Not Exist Error
Fix 'column does not exist' SQL errors in PostgreSQL, MySQL, and other databases when querying or migrating schemas.
What Does This Error Mean?
The 'column does not exist' error means the SQL query references a column that is not present in the table schema. This can happen due to missing migrations, incorrect column names, or quoting issues.
Common Causes
Column was added in a migration that hasn't been run yet
Typo in the column name
Mixed case column names without proper quoting
Querying the wrong table or schema
Using an alias that shadows the actual column name
ORM model not synced with database schema
How to Fix It
Check table schema
Verify the columns in your table match your query.
-- PostgreSQL: describe table \d table_name -- Or query information_schema SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'users' ORDER BY ordinal_position; -- MySQL DESCRIBE users;
Handle column case sensitivity
Unquoted identifiers in PostgreSQL are case-folded to lowercase.
-- ❌ Mixed case column SELECT "UserId" FROM users; -- Only works if column is literally "UserId" -- ✅ Use lowercase (PostgreSQL folds unquoted names) SELECT userid FROM users; -- OR quote exactly SELECT "UserId" FROM users; -- Column must be defined as "UserId"
Run pending migrations
Ensure all database migrations have been applied.
# Prisma npx prisma migrate deploy # TypeORM npx typeorm migration:run # Sequelize npx sequelize-cli db:migrate # Knex npx knex migrate:latest
Related Tools
Use these tools to debug and fix this error:
Related Errors
Other common errors in this category:
401 Unauthorized Error
Learn what a 401 Unauthorized error means, common causes, and how to fix authentication failures in your web applications.
403 Forbidden Error
Learn what 403 Forbidden means, how it differs from 401, and how to fix access denied errors in your applications.
404 Not Found Error
Learn what 404 Not Found means, common causes, and how to fix broken links and missing resources on your website or API.
429 Too Many Requests Error
Learn what 429 Too Many Requests means, how rate limiting works, and how to handle or avoid hitting API rate limits.