# PostgreSQL: ERROR: column "x" does not exist

**Code:** `42703` · **Category:** PostgreSQL · **Seen on:** PostgreSQL

PostgreSQL can’t find the column — a missing migration, a case-sensitive quoted name, or a string literal written in double quotes.

## Meaning

Two PostgreSQL-specific traps cause most of these: unquoted identifiers are folded to lower case (a column created as `"createdAt"` must always be quoted), and double quotes mean *identifier*, not string — `WHERE status = "paid"` looks for a column named paid.

## Common causes

- String value in double quotes (`"paid"` instead of `'paid'`)
- Mixed-case column created with quotes, queried without (`createdAt` → `createdat`)
- Migration adding the column not run
- Column alias used in WHERE (aliases only exist in ORDER BY/outer query)

## Quick fix

1. Use single quotes for strings
2. Quote mixed-case names exactly (`"createdAt"`) — or rename columns to snake_case
3. Run pending migrations
4. Move alias-based filters into a subquery or repeat the expression

## Detailed fix by platform

### PostgreSQL

1. Common mistakes:

```sql
SELECT * FROM orders WHERE status = "paid";   -- ❌ column "paid" does not exist
SELECT * FROM orders WHERE status = 'paid';   -- ✅

SELECT "createdAt" FROM users;                -- ✅ if the column was created with quotes
\d users                                      -- psql: list real column names
```


## How to diagnose

1. **Quotes** — Double quotes around a value?
2. **Case** — How is the column really named (\d table)?
3. **Migrations** — Run on this database?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/postgresql/column-does-not-exist)
