SQLSTATE 42703 ERROR Class 42: Syntax Error or Access Rule Violation

undefined_column column “…” does not exist — 42703

PostgreSQL error "column "…" does not exist" (SQLSTATE 42703): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

A query referenced a column that does not exist on any table currently in scope. The name resolved to no column in the FROM list — or it exists on a table you did not actually join.

  • The statement aborts with SQLSTATE 42703.
  • PostgreSQL often appends a HINT suggesting the closest existing column.
  • Frequently caused by a typo, wrong case, or a forgotten JOIN.

What the server log shows

ERROR:  column "totl" does not exist
LINE 1: SELECT totl FROM orders;
               ^
HINT:  Perhaps you meant to reference the column "orders.total".
STATEMENT:  SELECT totl FROM orders;

Why PostgreSQL raises this — what the manual says

Section 4.2.2 Column References:

“correlation is the name of a table (possibly qualified with a schema name), or an alias for a table defined by means of a FROM clause.”

After resolving the tables in FROM, the planner matches each column reference against their columns. A name that matches nothing yields 42703. As with tables, unquoted column names fold to lower case, so a column created as "userId" must be quoted to be found.

Common causes

  • A typo in the column name (note the HINT in the message).
  • Wrong case on a column that was created with quotes ("userId").
  • The column belongs to a table not included in the FROM/JOIN.
  • A renamed or dropped column the query still references.
  • Confusing a value with an identifier — string literals need single quotes.

How to fix it

  1. List the table’s columns: \d orders in psql.
  2. Fix the spelling/case, or quote a case-sensitive name exactly: "userId".
  3. Add the missing table to the FROM/JOIN clause.
  4. If you meant a string value, wrap it in single quotes: 'pending', not pending.

Diagnostic query

-- List the columns of a table
SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'orders'
ORDER BY ordinal_position;

Compare the names exactly — watch for case and underscores.

Related & next steps

Reference: PostgreSQL 18 Section 4.2.1 “Column References”.

Was this helpful?