Query variables
Reuse one SQL query with different values using placeholders such as :user_id, {{date}} or ${id}. See every supported syntax and try it live.
Put a placeholder in your SQL where a value goes. When you run the query, RowDex asks for a value for each placeholder and substitutes it. It is ideal for saved queries you re-run with a new user ID or date range.
Supported syntax#
| Style | Example |
|---|---|
| Colon | :order_id |
| Mustache | {{ order_id }} |
| Dollar-brace | ${order_id} |
| Hash-brace | #{order_id} |
| Percent | %order_id% |
| Positional | ? or ?1 |
The same name can appear several times, in any style, and RowDex asks for it once. @name is deliberately not supported, because it collides with email addresses and MySQL user variables.
Try it#
Edit the query and fill in the values. This demo follows the same rules as the app.
How values are inserted#
- Numbers are inserted as they are:
42,-3.5. - Text is wrapped in single quotes and escaped for you:
O'Brienbecomes'O''Brien'. - NULL or an empty value becomes
NULL. - A value you already wrapped in quotes is used exactly as typed.
What is not treated as a variable#
Placeholders inside string literals, quoted identifiers, comments and dollar-quoted blocks are left alone. So WHERE name LIKE '%term%' and a PostgreSQL cast like created_at::date run as written.
Was this page helpful?