// SQLite error reference

SQLITE_RANGE: column index out of range

A parameter number passed to an sqlite3_bind function, or a column number passed to an sqlite3_column function, is outside the valid range.

Result code
SQLITE_RANGE
Name
25
Category
Primary result codes
Error message
column index out of range

What it means

SQLITE_RANGE (25) means a bind or column index doesn't exist in the statement. Parameter numbers start at 1, and the highest is the number of ? placeholders (or the largest ?NNN). Language bindings report the same mistake when you pass more values than the statement has placeholders, for example Python's Incorrect number of bindings supplied.

Common causes

  • Binding parameter 0, or one more parameter than the statement has.
  • Passing a list of values that doesn't match the number of ? placeholders.
  • Reading a column index beyond the number of result columns.
  • Putting ? inside quotes, where it is a literal question mark, not a placeholder.

How to fix it

  1. Count the placeholders and pass exactly that many values. Bind indexes start at 1.

  2. Use named parameters to avoid counting mistakes.

    SELECT * FROM users WHERE email = :email AND status = :status;
  3. Never quote a placeholder: write WHERE name = ?, not WHERE name = '?'.

Related errors

More primary result codes errors

The code and message text are from the SQLite result and error codes documentation. Browse the full SQLite error list or search every database error.

// fewer errors, faster fixes

Work on SQLite in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQLite and the other databases you use.