Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

E0002 column-not-found

Referenced column does not exist in table.

CodeNameCategoryDefault
E0002column-not-foundcorrectnesserror

What it reports

A column reference doesn't match any column of the tables, views, CTEs or subqueries in scope.

Example

SELECT naem FROM users;
error[E0002]: Column 'naem' not found in table 'users'
  --> q.sql:1:8
    |
  1 | SELECT naem FROM users;
    |        ^^^^
    = help: Did you mean 'name'?

Fixed:

SELECT name FROM users;

Notes

  • Typos, and columns renamed or dropped by a migration. This is the most common way a schema change breaks a query in another file. The help says what became of the column and names the schema file and line of the ALTER TABLE that changed it, so you can find the migration without searching:

    = help: 'body' was renamed to 'content' in db/migrations/0003_rename_body.sql:2
    = help: 'nick' was dropped in db/migrations/0004_drop_nick.sql:1
    

    Paths are shown the way the schema files were given (relative to the current directory, or to the workspace in the editor). When the ALTER TABLE is in the query file itself, the help says at line N of this file.

  • Columns of a subquery or CTE that the subquery doesn't select.

  • PostgreSQL: a column created with a quoted name that is not all lowercase ("authorId", as Prisma migrations create them) is matched only by a quoted reference with the same case. PostgreSQL folds the unquoted authorId to authorid, so sqlsift reports it with the hint Column names are case-sensitive when quoted; did you mean "authorId"?. Columns created unquoted or all lowercase match references in any case, and other dialects match column names case-insensitively.

Configuring

# sqlsift.toml
[rules]
column-not-found = "warn"   # or "off"

Or for a single line: -- sqlsift:disable E0002. The examples use the schema on the Rules page.