“Referenced Column Not Found” — Fix This SQL Error
No table in the FROM clause has a column by that name. Usually a typo or a table you did not join.
- DuckDB
-
Binder Error: Referenced column "prodct_price" not found in FROM clause! - PostgreSQL
-
column "prodct_price" does not exist - MySQL
-
Unknown column 'prodct_price' in 'field list'Error 1054.
- SQL Server
-
Invalid column name 'prodct_price'. - Oracle
-
ORA-00904: "PRODCT_PRICE": invalid identifier - SQLite
-
no such column: prodct_price
The symptom
The query names a column and the database answers Referenced column "prodct_price" not found in FROM clause. The statement parsed correctly, so the shape of the SQL is fine. The problem is that the name does not resolve to anything the query can see.
Why it happens
A column reference is resolved against the tables in the FROM
clause, and nothing else. Three causes cover almost every case:
- The name is misspelled, as in the bench below.
- The column exists, but on a table you did not join, so it is not in scope.
- The column was renamed by an alias earlier in the query, and the old name no longer exists at this point.
The message names the column it could not resolve. Compare that string against the table's real column list before assuming the table is wrong.
The fix
Correct the spelling to price. If the name looks right, list
the columns the table actually has and compare, using
describe products in DuckDB or the equivalent in your engine;
SHOW TABLES and DESCRIBE
lists the command for each database.
When the column belongs to another table, add the join that brings it into scope, then qualify the reference with the table alias so it is unambiguous.
select product_name, prodct_price
from products
order by prodct_price desc
Running it raises
not found in FROM clause.
select product_name, price
from products
order by price desc
A column referenced in ORDER BY is resolved after the
SELECT list, so an output alias works there. The same alias in
WHERE is not portable. See
filtering on a SELECT alias.
How other engines word it
| Engine | Message |
|---|---|
| DuckDB | Binder Error: Referenced column "prodct_price" not found in FROM clause! |
| PostgreSQL | column "prodct_price" does not exist |
| MySQL | Unknown column 'prodct_price' in 'field list' Error 1054. |
| SQL Server | Invalid column name 'prodct_price'. |
| Oracle | ORA-00904: "PRODCT_PRICE": invalid identifier |
| SQLite | no such column: prodct_price |
Related errors
- Fix “Ambiguous Column Reference” in a SQL JOIN
Both joined tables have that column name, so the database refuses to guess.
- Fix “Column Not Found” When Filtering on a SQL Alias
In logical order, WHERE comes before SELECT assigns aliases, so many engines reject the alias there.
- Fix “Syntax Error at or Near” in SQL
The parser stopped at the first word it could not use. The quoted token is where it gave up, not always where the mistake is.
Learn more
Related
Understand tables, rows, columns, and queries.
Clause order and the shape of a SELECT query.
SELECT, WHERE, ORDER BY, and LIMIT at a glance.
Learn the basic shape of relational data.
Run queries and read results in the browser.
WHERE is evaluated before SELECT aliases exist.