--- title: "select-statement a [[param &1 is c], d,e, f,g,h,i,j], default k,l,m,n dbAlias is b" slug: "basic-db-look-up" updated: 2026-08-12T11:49:04Z published: 2026-08-12T11:49:04Z canonical: "docs.lobstersoftware.com/basic-db-look-up" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # select-statement a [[param &1 is c], d,e, f,g,h,i,j], default k,l,m,n dbAlias is b This function runs an SQL select statement **a** on the database represented by alias **b**. Placeholders in the form `&parameterNumber` in the statement are replaced by the values of parameters **c** to **j**. Characters required for valid syntax (for example, quotes around strings) must already be part of the statement. The function automatically limits the number of selected result rows to `1`. If the database returns a result row, the function returns the value of the first column. Otherwise, it returns **k**. If the result set contains columns of type BLOB, parameter **l** controls the encoding. Set **l** to `true` to write the binary data Base64-encoded to the result lists. Otherwise, the data remains unchanged. If there are no such columns in the result set, the parameter value has no effect. > [!WARNING] > **IMPORTANT:** > > In addition to the `&parameterNumber` notation, you can also use the notation for prepared statements in the form `@parameterNumber:parameterType@`. Prefer prepared statements, because they prevent SQL injection attacks. ## Parameters | Parameter | Description | | --- | --- | | a | SQL statement to run. | | b | The database alias. | | c | (optional) Parameter `&1` in the statement. | | d | (optional) Parameter `&2` in the statement. | | e | (optional) Parameter `&3` in the statement. | | f | (optional) Parameter `&4` in the statement. | | g | (optional) Parameter `&5` in the statement. | | h | (optional) Parameter `&6` in the statement. | | i | (optional) Parameter `&7` in the statement. | | j | (optional) Parameter `&8` in the statement. | | k | (optional) Return value if the database does not return a result. | | l | (optional) `true` if data from a column of type BLOB should be added to the result lists Base64-encoded. Default: `false`. | | m | (optional) `true` for read-only mode. Default: `false`. | | n | (optional) If `true`, the function ignores SQL errors reported by the database. Default: (== `false`). | ## Examples Assume a table `zipcodes` that contains the ZIP codes of Germany (an imaginary 20000 entries). | Parameter a | b | c | d-j | k | l | m | n | Result | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `select zipcode from zipcodes` | testdb | | | unknown | | | | 01067 | | `select city from zipcodes where zipcode = &1` | testdb | 80336 | | unknown | | | | Munich | | `select city from zipcodes where zipcode = &1` | testdb | 00000 | | unknown | | | | unknown | | `select city from zipcodes where zipcode = @1:i@` | testdb | 80336 | | unknown | | | | Munich | | `select city from zipcodes where zipcode = @1:i@` | testdb | 00000 | | unknown | | | | unknown | | `select pin from atmdata where username = '&1' and passwd = '&2'` | testdb | root | secret | unknown | | | | 4711 | | `select pin from atmdata where username = '&1' and passwd = '&2'` | testdb | root | `' or ''='` | unknown | | | | 4711 | | `select pin from atmdata where username = @1:s@ and passwd = @2:s@` | testdb | root | `' or ''='` | unknown | | | | unknown | | `select pin from atmdata where username = &1 and passwd = &2` | testdb | root | secret | unknown | | | | Error, because text literals must be enclosed in quotes. |