Home / Learn Secure SQL / Named vs Positional Parameters

Named vs Positional Parameters

Two placeholder styles, same underlying safety.

In shortTwo placeholder styles, same underlying safety.

What's actually going on

Two stylesPositionalSELECT * FROM t WHERE a=? ANDb=?Order mattersNamedSELECT * FROM t WHERE a=:a ANDb=:bOrder does not matter
Two styles

The basic idea

Positional placeholders (like ? or $1) are filled in order; named placeholders (like :email or @email) are filled by name. Both are equally safe; the choice is about readability, not security.

Why this comes up

Named parameters read better in long queries with many values, especially when the same value is used more than once; positional parameters are simpler for short queries.

The mechanics

Use whichever style your driver supports and your team prefers consistently; never fall back to string-building just because a driver only supports one style.

Where it is used

  • Web application code review
  • Backend development
  • Database administration
Both styles in SQLiteSQL: edit and run

SQLite (like most drivers) supports both; pick one style and use it consistently in a codebase.

Quick check

1. Named and positional parameters differ mainly in...