--- title: "select into map(a,b,[param &1 equals c], d,e, f,g,h,i,j], delimiter k, map l,m,n,o,p)" slug: "basic-db-select-into-map" updated: 2026-08-12T11:34:21Z published: 2026-08-12T11:34:21Z canonical: "docs.lobstersoftware.com/basic-db-select-into-map" --- > ## 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 into map(a,b,[param &1 equals c], d,e, f,g,h,i,j], delimiter k, map l,m,n,o,p) This function executes the SQL SELECT statement **a** on the database with the alias **b**. It replaces placeholders in the format *¶meter_number* in the statement with the values from parameters ***c*** through ***j***. Any characters required for valid statement syntax (for example, quotation marks around string values) must already be present in the statement. The result set is not limited. If you need fewer rows, use a LIMIT clause in the SQL statement. The result table is written to a map named **l**. The value of the first column serves as the key. The remaining columns in each result row are separated by the delimiter **k** and concatenated into a single string. This string is stored as the value under the key in the map. Before writing, the function clears the map unless parameter **o** suppresses this. The return value of the function is the number of rows returned. If the result set contains columns of type BLOB, parameter **m** determines whether binary data is Base64-encoded in the result lists (map entries). When **m** equals *true*, the function Base64-encodes the data. Otherwise, data remains unchanged. If the result set contains no such columns, this parameter has no effect. > [!WARNING] > **IMPORTANT:** > > In addition to the *¶meter_number* syntax, you can also use the syntax for prepared statements in the form *@parameter_number:parameter_type@*. Prefer this syntax because it prevents SQL injection attacks. Within prepared statements, parameters replace only individual values. SQL syntax such as value lists for *IN*, table or column names, operators, sort orders, or complete SQL fragments cannot be passed through placeholders. ## Parameters | Parameter | Description | | --- | --- | | a | SQL statement to execute. | | b | The database alias. | | c | (optional) Replaces placeholder *&1* in the statement. | | d | (optional) Replaces placeholder *&2* in the statement. | | e | (optional) Replaces placeholder *&3* in the statement. | | f | (optional) Replaces placeholder *&4* in the statement. | | g | (optional) Replaces placeholder *&5* in the statement. | | h | (optional) Replaces placeholder *&6* in the statement. | | i | (optional) Replaces placeholder *&7* in the statement. | | j | (optional) Replaces placeholder *&8* in the statement. | | k | Delimiter string. | | l | Name of the map. | | m | (optional) *true* if data from a BLOB column should be Base64-encoded in the result lists. Default: *false* | | n | *true* for read-only mode. | | o | (optional) *true* if the map should not be cleared before writing. Default: *false* | | p | (optional) *true* to ignore SQL errors reported by the database. Default: (== *false*). | ## Examples Assume a table *zipcodes* containing postal codes for Germany (20,000 entries in this example). | Parameter a | b | c | d…j | k | l | m | n | o | p | Result | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | select zipcode, city, county from zipcodes | testdb | | | ; | ZIPS | | | false | | 20000 | The result is a map ZIPS containing 20,000 entries with the postal code as key and city and state as value. For example: {*80336=Munich;Bavaria*}. | Parameter a | b | c | d…j | k | l | m | n | o | p | Result | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | select zipcode, city, county from zipcodes where zipcode = &1 | testdb | 80336 | | ; | ZIPS | | | false | | 1 | | select zipcode, city, county from zipcodes where zipcode = @1:i@ | testdb | 80336 | | ; | ZIPS | | | false | | 1 | Produces the map with only the entry shown above. | Parameter a | b | c | d..j | k | l | m | n | o | p | Result | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | select zipcode, city, county from zipcodes where county = '&1' | testdb | Bayern | | ; | ZIPS | | | false | | 1500 | | select zipcode, city, county from zipcodes where county = @1:s@ | testdb | Bayern | | ; | ZIPS | | | false | | 1500 | | select zipcode, city, county from zipcodes where county = &1 | testdb | Bayern | | ; | ZIPS | | | false | | Error: string literals must be enclosed in quotation marks. | In the first two cases, produces the map with all Bavarian postal codes.