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

duplicate_column column “…” specified more than once — 42701

PostgreSQL error "column "…" specified more than once" (SQLSTATE 42701): 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 statement listed the same column name twice where each column may appear only once — typically an INSERT column list, an UPDATE … SET, or a CREATE TABLE definition. PostgreSQL raises SQLSTATE 42701 (duplicate_column).

  • The statement aborts at parse time.
  • The duplicated column name is named in the message.
  • Often the result of code that builds column lists dynamically.

What the server log shows

ERROR:  column "email" specified more than once
LINE 1: INSERT INTO users (email, email) VALUES ('a','b');
                                  ^

Why PostgreSQL raises this — what the manual says

As the INSERT reference (Parameters) explains:

Each column of the target table may be named only once in an INSERT (or UPDATE SET) column list; listing the same column twice is ambiguous about which value should apply, so PostgreSQL rejects it.

PostgreSQL validates that the target column list (or SET list, or table definition) contains each column at most once before assigning values. A repeat would make the target value ambiguous, so analysis fails with 42701.

Common causes

  • Dynamically generated SQL that appends a column twice.
  • Copy-paste duplication in an INSERT/UPDATE column list.
  • An ORM mapping the same attribute to two column entries.

How to fix it

  1. Remove the duplicate from the column list or SET clause.
  2. De-duplicate the column set in the code that builds the SQL.
  3. For UPDATE, combine the intended value into a single assignment.

Related & next steps

Reference: PostgreSQL 18 — INSERT.

Was this helpful?