Fix “Missing FROM-Clause Entry for Table” in SQL
A column is prefixed with a table name or alias the FROM clause doesn't define. Use the alias you gave, or join the table.
- DuckDB
-
Binder Error: Referenced table "cat" not found! Candidate tables: "c" - PostgreSQL
-
missing FROM-clause entry for table "cat"Using a table's name after giving it an alias is a separate message: invalid reference to FROM-clause entry for table "products", with a hint naming the alias.
- SQL Server
-
The multi-part identifier "cat.category_name" could not be bound.Msg 4104.
- MySQL
-
Unknown column 'cat.category_name' in 'where clause'Error 1054, the same error as a misspelled column.
- Oracle
-
ORA-00904: "CAT"."CATEGORY_NAME": invalid identifier - SQLite
-
no such column: cat.category_nameChecked on SQLite 3.53.
The symptom
A column carries a prefix, like cat.category_name, and the
database says it has no table called cat. PostgreSQL calls it a
missing FROM-clause entry, SQL Server says the multi-part identifier could
not be bound, and DuckDB says the referenced table was not found. The column
may be fine. The part before the dot names nothing in FROM.
The prefix has to match a name the FROM clause defines: the
table's alias if it has one, or its name if it doesn't. In the bench below,
categories is called c, and the WHERE
line asks for cat.
The fix: use the name FROM gave it
select p.product_name, c.category_name
from products as p
join categories as c on c.category_id = p.category_id
where cat.category_name = 'Tools'
order by p.product_name;
Running it raises
Referenced table "cat" not found.
select p.product_name, c.category_name
from products as p
join categories as c on c.category_id = p.category_id
where c.category_name = 'Tools'
order by p.product_name;
DuckDB helps here: Candidate tables: "c" lists every name the
query can use, so compare the prefix against that list.
Three other ways to get it
The table's own name after an alias. Once
products is called p, the name
products is gone for the rest of the query:
select products.product_name
from products as p; select p.product_name
from products as p
limit 3;
PostgreSQL words this case differently:
invalid reference to FROM-clause entry for table "products",
with a hint naming the alias.
A table that was never joined. Naming a table in
SELECT doesn't bring it into the query. Only FROM
and JOIN do:
select o.order_id, c.first_name
from orders as o; select o.order_id, c.first_name
from orders as o
join customers as c on c.customer_id = o.customer_id
order by o.order_id
limit 3; An alias from inside a subquery. Names given inside a subquery stay inside it. Outside, the subquery is known only by its own alias:
select o.order_id
from (
select *
from orders as o
where status = 'pending'
) as pending; select pending.order_id
from (
select *
from orders as o
where status = 'pending'
) as pending
order by pending.order_id;
The same goes for a CTE: refer to it by the name after with,
not by an alias used inside it.
When the prefix is right and the column after the dot is misspelled, the error is about the column instead: Referenced column not found. MySQL and SQLite use their column error for both, so check the prefix and the column name.
How other engines word it
| Engine | Message |
|---|---|
| DuckDB | Binder Error: Referenced table "cat" not found! Candidate tables: "c" |
| PostgreSQL | missing FROM-clause entry for table "cat" Using a table's name after giving it an alias is a separate message: invalid reference to FROM-clause entry for table "products", with a hint naming the alias. |
| SQL Server | The multi-part identifier "cat.category_name" could not be bound. Msg 4104. |
| MySQL | Unknown column 'cat.category_name' in 'where clause' Error 1054, the same error as a misspelled column. |
| Oracle | ORA-00904: "CAT"."CATEGORY_NAME": invalid identifier |
| SQLite | no such column: cat.category_name Checked on SQLite 3.53. |
Related errors
- 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.
- Fix “Ambiguous Column Reference” in a SQL JOIN
Both joined tables have that column name, so the database refuses to guess.
- Fix “Catalog Error: Table Does Not Exist” in SQL
No table by that name is visible to the query. A typo, a missing schema, or a table that's already gone.