---
title: Mustache parameter syntax
description: Learn about mustache parameter syntax in the Databricks SQL editor.
canonical_url: https://docs.databricks.com/aws/en/sql/user/sql-editor/mustache-parameters
---

# Mustache parameter syntax

> [!IMPORTANT]
>
> Mustache parameter syntax is supported in the legacy SQL editor only. Databricks recommends using [named parameter markers](https://docs.databricks.com/aws/en/sql/user/queries/query-parameters.md) for new queries. If you copy a query using mustache syntax into a notebook, AI/BI dashboard dataset editor, or Genie Agent, you must convert it to named parameter markers before it will run.

In the legacy SQL editor, any string wrapped in double curly braces (`{{ }}`) is treated as a query parameter. A widget appears above the results pane where you set the parameter value.

## Add a mustache parameter

1. Press `Cmd + I`. The parameter is inserted at the cursor position and the **Add Parameter** dialog appears.
2. Enter the **Keyword**, optionally change the **Title**, and select a **Type**.
3. Click **Add Parameter**.
4. Set the parameter value in the widget.
5. Click **Apply Changes**.
6. Click **Save**.

Alternatively, type `{{ }}` directly in the query and click the gear icon in the parameter widget to configure it.

To re-run the query with a different value, update the widget and click **Apply Changes**.

## Edit, remove, and reorder parameters

**Edit**: Click the gear icon beside the parameter widget. To prevent users who don't own the query from changing the parameter value, click **Show Results Only**.

**Remove**: Delete the parameter marker from the query. The widget is removed automatically.

**Reorder**: Click and drag parameter widgets to the desired order.

## Widget types

The following widget types are available:

### Text

Takes a string as input. Backslash, single, and double quotation marks are escaped automatically. Databricks adds quotation marks around the value.

```sql
SELECT * FROM samples.tpch.customer WHERE c_name = {{ name_param }}
```

### Number

Takes a number as input.

```sql
SELECT * FROM users WHERE age = {{ number_param }}
```

### Date and Time

Parameterizes date and timestamp values. Three options are available:

| Type                             | Precision |
| -------------------------------- | --------- |
| **Date**                         | Day       |
| **Date and Time**                | Minute    |
| **Date and Time (with seconds)** | Second    |

All date and time values are passed as string literals and must be wrapped in single quotation marks in your query:

```sql
SELECT * FROM usage_logs WHERE date = '{{ date_param }}'
```

When you select a **Range** option, Databricks creates two parameters using `.start` and `.end` suffixes:

```sql
SELECT * FROM usage_logs
WHERE modified_time > '{{ date_range.start }}'
AND modified_time < '{{ date_range.end }}'
```

> [!NOTE]
>
> The Date Range widget returns correct results only for `DATE`-type columns. For timestamp columns, use a Date and Time Range widget.

**Dynamic date values**: Date widgets include a blue lightning bolt icon. Click it to select dynamic values such as `today`, `yesterday`, `this week`, `last week`, `last month`, or `last year`. These values update automatically.

> [!IMPORTANT]
>
> Dynamic date values are not compatible with scheduled queries.

### <a id="dropdown-list" />Dropdown List

Restricts input to a predefined static list. Supports both single-value and multi-value selection.

* **Single value**: Wrap the parameter in single quotation marks in the query.
* **Multi-value**: Enable **Allow multiple values** in the widget settings. Use the **Quotation** option to control whether values are wrapped in single quotes, double quotes, or none. Update your `WHERE` clause to use `IN`:

  ```sql
  SELECT * FROM orders WHERE status IN ( {{ status_param }} )
  ```

  With double quotation marks selected, the query resolves to: `WHERE status IN ("value1", "value2", "value3")`.

Dropdown List values are strings. To use dates or timestamps, enter them in the format your data source requires.

### <a id="query-based-dropdown-list" />Query-Based Dropdown List

Populates dropdown choices from a saved query. Behaves like Dropdown List but the options are dynamic.

1. Under **Type** in the settings panel, select **Query Based Dropdown list**.
2. Click the **Query** field and select a saved query.

If the query returns more than one column, Databricks uses the first column. If the query returns columns named `name` and `value`, the widget displays the `name` column but passes the associated `value` to the query at runtime.

Example:

```sql
SELECT user_uuid AS 'value', username AS 'name' FROM users
```

| value | name         |
| ----- | ------------ |
| 1001  | John Smith   |
| 1002  | Jane Doe     |
| 1003  | Bobby Tables |

The value passed to the database at runtime is `1001`, `1002`, or `1003`, not the display name.

> [!NOTE]
>
> Performance degrades if the source query returns a large number of records.
