Lab-verifiedReproduced and fixed on PostgreSQL 17.12 · 2026-12-01 · container image postgres:17
42703 means a column name in the query matches no column of the tables in FROM. The message shows the name PostgreSQL looked for, already folded to lowercase, and the HINT line often suggests the closest real column.
Compare the name in the message with information_schema.columns. Watch for case: userName without quotes is looked up as username.
01The column name is misspelled
The column is created_at, but the query says create_at. PostgreSQL's HINT already points to it: Perhaps you meant to reference the column "customers.created_at". Listing the table's columns confirms the real name.
Setup
CREATE TABLE customers (id int PRIMARY KEY, name text, created_at timestamp);
INSERT INTO customers VALUES (1, 'Kim', '2026-11-01 09:00');CREATE TABLE
INSERT 0 1SELECT id, name, create_at FROM customers;ERROR: 42703: column "create_at" does not exist
LINE 1: SELECT id, name, create_at FROM customers;
^
HINT: Perhaps you meant to reference the column "customers.created_at".SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'customers' ORDER BY ordinal_position; column_name | data_type
-------------+-----------------------------
id | integer
name | text
created_at | timestamp without time zone
(3 rows)SELECT id, name, created_at FROM customers; id | name | created_at
----+------+---------------------
1 | Kim | 2026-11-01 09:00:00
(1 row)02Using a SELECT alias (AS total) in WHERE
The query named an expression price * qty AS total and filtered with WHERE total >= 100000, which failed with column "total" does not exist. The ^ on LINE 3 points at total in WHERE. WHERE is evaluated before the SELECT list, so the alias does not exist yet. The same alias works fine in ORDER BY total.
Setup
CREATE TABLE order_items (order_id int, product text, price numeric, qty int);
INSERT INTO order_items VALUES (1, 'Keyboard', 45000, 3), (2, 'Mouse', 12000, 2), (3, 'Monitor', 210000, 1);CREATE TABLE
INSERT 0 3SELECT order_id, product, price * qty AS total
FROM order_items
WHERE total >= 100000;ERROR: 42703: column "total" does not exist
LINE 3: WHERE total >= 100000;
^SELECT order_id, product, price * qty AS total
FROM order_items
ORDER BY total DESC; order_id | product | total
----------+----------+--------
3 | Monitor | 210000
1 | Keyboard | 135000
2 | Mouse | 24000
(3 rows)Moving the calculation into a subquery and filtering outside with WHERE total >= 100000 returned 2 rows: Keyboard (135000) and Monitor (210000). Repeating the expression, WHERE price * qty >= 100000, also works.
SELECT *
FROM (SELECT order_id, product, price * qty AS total FROM order_items) t
WHERE total >= 100000
ORDER BY order_id; order_id | product | total
----------+----------+--------
1 | Keyboard | 135000
3 | Monitor | 210000
(2 rows)03The column was created with quotes and mixed case
An ORM or migration created the column as "userName". Without quotes, userName in the query is folded to username, which does not exist. The message shows the lowercased username, and the HINT shows the real users.userName.
Setup
CREATE TABLE users (id int PRIMARY KEY, "userName" text, "createdAt" date);
INSERT INTO users VALUES (1, 'kim', '2026-11-01');CREATE TABLE
INSERT 0 1SELECT id, userName FROM users;ERROR: 42703: column "username" does not exist
LINE 1: SELECT id, userName FROM users;
^
HINT: Perhaps you meant to reference the column "users.userName".SELECT column_name FROM information_schema.columns WHERE table_name = 'users' ORDER BY ordinal_position; column_name
-------------
id
userName
createdAt
(3 rows)SELECT id, "userName" FROM users; id | userName
----+----------
1 | kim
(1 row)04A string value was written in double quotes
In PostgreSQL, double quotes mean an identifier (a column or table name), not a string. WHERE status = "paid" looks for a column named paid. This often happens with SQL copied from MySQL. Here the HINT even suggests an unrelated column (orders.id), so do not trust it blindly.
String values take single quotes: WHERE status = 'paid'.
Setup
CREATE TABLE orders (id int PRIMARY KEY, status text);
INSERT INTO orders VALUES (1, 'paid'), (2, 'cancelled');CREATE TABLE
INSERT 0 2SELECT id, status FROM orders WHERE status = "paid";ERROR: 42703: column "paid" does not exist
LINE 1: SELECT id, status FROM orders WHERE status = "paid";
^
HINT: Perhaps you meant to reference the column "orders.id".SELECT DISTINCT status FROM orders ORDER BY status; status
-----------
cancelled
paid
(2 rows)SELECT id, status FROM orders WHERE status = 'paid'; id | status
----+--------
1 | paid
(1 row)05A shared updated_at trigger on a table without that column (record "new" has no field)
One trigger function that only does NEW.updated_at := now() was attached to several tables. products has updated_at and works, but an UPDATE on categories, which does not, failed with record "new" has no field "updated_at". That is SQLSTATE 42703 too. CONTEXT shows the function and line (set_updated_at() line 3).
Setup
CREATE FUNCTION set_updated_at() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN
NEW.updated_at := now();
RETURN NEW;
END;
$$;
CREATE TABLE products (id int PRIMARY KEY, name text, updated_at timestamptz);
CREATE TABLE categories (id int PRIMARY KEY, name text);
CREATE TRIGGER trg_products_updated BEFORE UPDATE ON products FOR EACH ROW EXECUTE FUNCTION set_updated_at();
CREATE TRIGGER trg_categories_updated BEFORE UPDATE ON categories FOR EACH ROW EXECUTE FUNCTION set_updated_at();
INSERT INTO products VALUES (1, 'Keyboard', NULL);
INSERT INTO categories VALUES (1, 'Input');CREATE FUNCTION
CREATE TABLE
CREATE TABLE
CREATE TRIGGER
CREATE TRIGGER
INSERT 0 1
INSERT 0 1UPDATE categories SET name = 'Input devices' WHERE id = 1;ERROR: 42703: record "new" has no field "updated_at"
CONTEXT: PL/pgSQL assignment "NEW.updated_at := now()"
PL/pgSQL function set_updated_at() line 3 at assignmentSELECT t.tgrelid::regclass AS table_name, t.tgname, p.proname AS function_name,
EXISTS (SELECT 1 FROM information_schema.columns c
WHERE c.table_schema = current_schema()
AND c.table_name = t.tgrelid::regclass::text
AND c.column_name = 'updated_at') AS has_updated_at
FROM pg_trigger t JOIN pg_proc p ON p.oid = t.tgfoid
WHERE NOT t.tgisinternal
ORDER BY 1; table_name | tgname | function_name | has_updated_at
------------+------------------------+----------------+----------------
products | trg_products_updated | set_updated_at | t
categories | trg_categories_updated | set_updated_at | f
(2 rows)Of the triggers using the same function set_updated_at, only categories shows has_updated_at = f.
ALTER TABLE categories ADD COLUMN updated_at timestamptz;ALTER TABLEAdding an updated_at timestamptz column to categories made the UPDATE succeed, and updated_at was filled in. If that table does not need the column, drop the trigger instead.
UPDATE categories SET name = 'Input devices' WHERE id = 1;
SELECT id, name, updated_at IS NOT NULL AS updated_at_set FROM categories;UPDATE 1
id | name | updated_at_set
----+---------------+----------------
1 | Input devices | t
(1 row)FAQ
How do I fix column does not exist in PostgreSQL?
Check the exact name in the message and the HINT line, then compare with information_schema.columns. Fix the spelling, quote mixed-case columns ("userName"), and use single quotes for string values.
Why does PostgreSQL say column does not exist when the column exists?
Usually because of case. A column created as "userName" keeps its capital letter, but unquoted userName is looked up as username. Use "userName" in the query.
Why does WHERE name = "value" give column does not exist?
Double quotes are for identifiers in PostgreSQL. "value" is read as a column name. Write strings in single quotes: 'value'.
What does SQLSTATE 42703 mean?
42703 is undefined_column: the query refers to a column that none of the tables in the statement has.
Why can I not use a column alias in WHERE in PostgreSQL?
WHERE runs before the SELECT list, so the alias does not exist yet. In the test, WHERE total >= 100000 failed with 42703; wrapping the calculation in a subquery and filtering outside worked. Aliases are allowed in ORDER BY.
What does record "new" has no field mean?
The trigger function writes NEW.<column> but that table has no such column. It happened with a shared updated_at trigger on a table without the column; finding the tables via pg_trigger and adding the column fixed it.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary roles created for the test, each owning a schema of the same name; postgres is the superuser. PostgreSQL 17.12