Skip to content
SQL errors/Fix “Referenced Column Not Found” in SQL
SQL error

Fix “Referenced Column Not Found” in SQL

No table in the FROM clause has a column by that name. Usually a typo or a table you did not join.

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 theFROM 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, usingdescribe products in DuckDB or the equivalent in your engine.

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.

Watch out

A column referenced in ORDER BY is resolved after theSELECT list, so an output alias works there. The same alias inWHERE is not portable. Seefiltering on a SELECT alias.

How other engines word it

EngineMessage
DuckDBBinder Error: Referenced column "prodct_price" not found in FROM clause!
PostgreSQLcolumn "prodct_price" does not exist
MySQLUnknown column 'prodct_price' in 'field list' (error 1054)
SQL ServerInvalid column name 'prodct_price'.
OracleORA-00904: "PRODCT_PRICE": invalid identifier
SQLiteno such column: prodct_price

Learn more