PostgreSQLERROR 42P01

PostgreSQL: Missing FROM-Clause Entry for Table

PostgreSQL raises this error when a column reference in the query includes a table alias or table name that has not been declared in the FROM clause. The table is not in scope.

Example Query

SELECT u.name, o.total
FROM users u
WHERE o.total > 100;
-- 'o' alias is not joined

Common Causes

  1. 1Referencing a table alias that was never added to the FROM/JOIN clause
  2. 2Copying a subquery and forgetting to include its source table
  3. 3Typo in a table alias

How to Fix It

Add the missing table to the FROM or JOIN clause. Verify all table aliases in the WHERE and SELECT clauses have a corresponding FROM/JOIN entry. Use explicit JOIN syntax instead of comma joins to make relationships visible.

Need a reliable database?

Try Supabase — free PostgreSQL with a generous free tier. No credit card required.

Get started free →

Got a query causing this error?

Paste it into SQLbuddy and get an instant plain-English explanation with optimization tips.

Analyze My Query →