#readwise
# SQL Language Expressions

## Metadata
- Author: [[sqlite.org]]
- Full Title: SQL Language Expressions
- URL: https://www.sqlite.org/lang_expr.html
## Highlights
### Parameters
A "variable" or "parameter" token specifies a placeholder in the expression for a value that is filled in at runtime using the [`sqlite3_bind()`](https://www.sqlite.org/lang_expr.html/c3ref/bind_blob.html) family of C/C++ interfaces. Parameters can take several forms:
| Parameter | Description |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `?NNN` | A question mark followed by a number `NNN` holds a spot for the **`NNN`-th parameter. `NNN` must be between 1 and [`SQLITE_MAX_VARIABLE_NUMBER`](https://www.sqlite.org/lang_expr.html/limits.html#max_variable_number)** |
| `?` | **A question mark that is not followed by a number creates a parameter with a number one greater than the largest parameter number already assigned.** If this means the parameter number is greater than [`SQLITE_MAX_VARIABLE_NUMBER`](https://www.sqlite.org/lang_expr.html/limits.html#max_variable_number), it is an error. This parameter format is provided for compatibility with other database engines. But **because it is easy to miscount the question marks, the use of this parameter format is discouraged. Programmers are encouraged to use one of the symbolic formats below or the `?NNN` format above instead.** |
| `:AAAA` | **A colon followed by an identifier name holds a spot for a [named parameter](https://www.sqlite.org/lang_expr.html/c3ref/bind_parameter_name.html) with the name `:AAAA`.** Named parameters are also numbered. The number assigned is one greater than the largest parameter number already assigned. If this means the parameter would be assigned a number greater than [`SQLITE_MAX_VARIABLE_NUMBER`](https://www.sqlite.org/lang_expr.html/limits.html#max_variable_number), it is an error. **To avoid confusion, it is best to avoid mixing named and numbered parameters.** |
| `@AAAA` | An "at" sign works exactly like a colon, except that the name of the parameter created is `@AAAA`. |
| `$AAAA` | A dollar-sign followed by an identifier name also holds a spot for a named parameter with the name `$AAAA`. The identifier name in this case can include one or more occurrences of "::" and a suffix enclosed in "(...)" containing any text at all. This syntax is the form of a variable name in the [Tcl programming language](http://www.tcl-lang.org/). The presence of this syntax results from the fact that SQLite is really a [Tcl extension](https://www.sqlite.org/lang_expr.html/tclsqlite.html) that has escaped into the wild. |
Parameters that are not assigned values using [`sqlite3_bind()`](https://www.sqlite.org/lang_expr.html/c3ref/bind_blob.html) are treated as `NULL`. The [`sqlite3_bind_parameter_index()`](https://www.sqlite.org/lang_expr.html/c3ref/bind_parameter_index.html) interface can be used to translate a symbolic parameter name into its equivalent numeric index. ([View Highlight](https://read.readwise.io/read/01k2vhrd9x84m3evrq2djeqbhq))
---