You look for one visitor in the museum log. The column name exists, the value Alex exists, and PostgreSQL says a column called Alex doesn't:
ERROR: column "Alex" does not exist
LINE 1: SELECT * FROM visitors WHERE name = "Alex";
^ERROR: column "x" does not exist means PostgreSQL read something in your query as a column name, and the table has no column with that name. Look at the name in the quotes: it's exactly what PostgreSQL looked for. In this example, it's Alex, a value you meant as text, because it was in double quotes, and in PostgreSQL double quotes mean "this is a name". The fix is single quotes. That's the most common cause, but there are four more, including capital letters, which work differently in PostgreSQL than in most other databases. This article explains each, with the exact output.
Try it yourself
Run this in psql, pgAdmin or any PostgreSQL tool:
CREATE TABLE visitors (id serial PRIMARY KEY, name text, room text, visit_date date);
INSERT INTO visitors (name, room, visit_date) VALUES
('Alex', 'Vault', '2026-12-01'),
('Sam', 'Lobby', '2026-12-02');Then:
SELECT * FROM visitors WHERE name = "Alex";You'll get the error above.
What the error means
Read it in parts:
ERROR: column "Alex" does not exist: the name PostgreSQL looked for, exactly as it understood it, including capital letters.LINE 1:and the^: the query and the exact spot.HINT:(when there is one): PostgreSQL's suggestion. Read it. It's often the answer.
Then ask: did I mean this as a column name at all? If not, it's a quoting problem. If yes, it's a spelling, capitals or alias problem.
Cause 1: double quotes around text
In SQL, the two kinds of quotes mean different things:
- Single quotes
'Alex'are text, a value. - Double quotes
"Alex"are a name, of a column or a table.
So name = "Alex" asks PostgreSQL to compare the name column with a column called Alex. The fix:
SELECT name FROM visitors WHERE name = 'Alex'; name
------
Alex
(1 row)If you come from Python or JavaScript, where both quote types make strings, this catches you every time at first. In SQL, text is always single quotes.
Text with no quotes at all
The same error appears when you forget the quotes completely:
UPDATE visitors SET room = Vault WHERE name = 'Sam';ERROR: column "vault" does not exist
LINE 1: UPDATE visitors SET room = Vault WHERE name = 'Sam';
^Without quotes, Vault is read as a name. And notice the message says "vault" in lowercase, not Vault. That's the next cause.
Cause 2: capital letters in names
PostgreSQL turns unquoted names into lowercase. SELECT Name FROM Visitors is read as SELECT name FROM visitors. Usually that's harmless, because tables created without quotes are lowercase too.
The trouble starts when a table was created with double quotes and capital letters, which often happens when a tool or a framework creates the tables for you:
CREATE TABLE "Orders" ("OrderId" int, "CustomerName" text);
SELECT CustomerName FROM "Orders";ERROR: column "customername" does not exist
LINE 1: SELECT CustomerName FROM "Orders";
^
HINT: Perhaps you meant to reference the column "Orders.CustomerName".PostgreSQL lowercased CustomerName to customername, but the real column is CustomerName, with capitals, because it was created in quotes. The HINT tells you exactly that. Two fixes:
- Quote it exactly as created:
SELECT "CustomerName" FROM "Orders";works. - Better, in your own tables: use lowercase names with underscores, like
customer_name, and never quote them. Then capitals never matter.
The table name has the same rule: SELECT customername FROM Orders fails with relation "orders" does not exist, because the table is "Orders" with a capital O. For that message, see SQLite: no such table, which also covers PostgreSQL's version.
Cause 3: a typo in the column name
SELECT nmae FROM visitors;ERROR: column "nmae" does not exist
LINE 1: SELECT nmae FROM visitors;
^
HINT: Perhaps you meant to reference the column "visitors.name".PostgreSQL suggests the closest existing column. It works with aliases too: SELECT v.nam FROM visitors v gave HINT: Perhaps you meant to reference the column "v.name".
To see every column of a table in psql, type \d visitors.
Cause 4: an alias used in WHERE
You can rename a column in the result with AS, but that new name doesn't exist yet when WHERE runs:
SELECT name, room AS place FROM visitors WHERE place = 'Vault';ERROR: column "place" does not exist
LINE 1: SELECT name, room AS place FROM visitors WHERE place = 'Vaul...
^The reason is the order in which SQL works: FROM and WHERE run before SELECT gives columns their new names. So in WHERE, use the original column: WHERE room = 'Vault'.
ORDER BY runs last, so the alias works there: ORDER BY place ran without error in our test.
The same in HAVING
SELECT name, COUNT(*) AS visits FROM visitors GROUP BY name HAVING visits > 0;ERROR: column "visits" does not exist
LINE 1: ...T(*) AS visits FROM visitors GROUP BY name HAVING visits > 0...
^In PostgreSQL, HAVING can't use the alias either. Repeat the expression: HAVING COUNT(*) > 0. (SQLite accepts the alias here, which is one of several small differences explained in our GROUP BY errors article.)
If you really want to filter on the new name, wrap the query, so the alias exists in the outer one:
SELECT * FROM (SELECT name, room AS place FROM visitors) v WHERE place = 'Vault';Cause 5: a wrong column in INSERT or UPDATE
In an INSERT, the message names the table too:
INSERT INTO visitors (name, rooms) VALUES ('Mia', 'Vault');ERROR: column "rooms" of relation "visitors" does not exist
LINE 1: INSERT INTO visitors (name, rooms) VALUES ('Mia', 'Vault');
^rooms versus room: singular and plural mix-ups are the most common column typos.
The same error in SQLite and MySQL
The idea is the same in every database, with different words:
- SQLite:
no such column: Alex. See SQLite: no such column. - MySQL:
Unknown column 'Alex' in 'where clause'(orin 'field list').
One difference matters: SQLite and MySQL don't lowercase names the way PostgreSQL does, so cause 2 is mostly a PostgreSQL problem.
Errors that look alike
relation "x" does not exist: the table isn't found, not the column.column reference "id" is ambiguous: the column exists in two joined tables. See ambiguous column name.must appear in the GROUP BY clause: the column exists, but can't be used that way in a grouped query. See GROUP BY errors.
Wrong fixes that don't help
- Putting double quotes around everything. Then every name must match its exact case, and text values become column names.
- Renaming your column to match the typo. Fix the query instead.
- Creating tables with capital letters in quotes. It works, but every query afterwards needs the quotes too.
A debugging walkthrough
- Read the name in the quotes. Is it a value you meant as text? Use single quotes.
- Is it lowercase while your column has capitals? The table was created with quoted names: quote the column exactly, or rename the column to lowercase.
- Read the
HINT. It often names the right column. - Is it an alias from
SELECT? Use the original column inWHEREandHAVING. - List the columns with
\d tablenameinpsql, and compare letter by letter.
Practice
Which of these work, with the visitors table above?
SELECT * FROM visitors WHERE room = 'Vault';SELECT * FROM Visitors WHERE Room = 'Vault';SELECT * FROM visitors WHERE room = "Vault";
Answers. (1) Works. (2) Works too: PostgreSQL lowercases Visitors and Room, and the table and column were created in lowercase. (3) column "Vault" does not exist: double quotes make it a name.
Frequently asked questions
What does "column does not exist" mean in PostgreSQL?
PostgreSQL read something in your query as a column name, and the table has no column with that name. Check quotes, capitals, aliases and spelling.
Why does PostgreSQL say a column doesn't exist when it does?
Usually because the column was created with capital letters in double quotes, and your query doesn't quote it. PostgreSQL lowercases unquoted names.
What's the difference between single and double quotes in PostgreSQL?
Single quotes are text values. Double quotes are names of columns and tables, and keep their exact capital letters.
Can I use a column alias in WHERE?
No. WHERE runs before the aliases from SELECT exist. Use the original column, or wrap the query in a subquery.
How do I see the columns of a table?
In psql, \d tablename. In any tool, SELECT column_name FROM information_schema.columns WHERE table_name = 'visitors';.
A quick checklist
- Text in single quotes, never double.
- Read the name in the error: lowercase where you expected capitals?
- Read the
HINT. - No
SELECTaliases inWHEREorHAVING. - Name your own columns in lowercase with underscores.
For a method that works on any error, read how to read an error message. The PostgreSQL documentation explains identifiers and quoting.
