Use dynamic SQL inputs
Reuse a query with different values by defining inputs rather than editing the SQL each time.
Before you start
Connect a SQL resource and open the SQL Query Builder. This example assumes an Orders table containing id, customer_id, and total. Use the table and column identifiers shown in your resource.
Define and use an input
Add a numeric input named
customer_idin the query's inputs.Enter a test value, such as
1.Insert the input into the query:
SELECT id, customer_id, total
FROM Orders
WHERE customer_id = {{params.customer_id}};Run the query using the test control and inspect the returned rows.
Change the test input to
2and run it again.Save the query after verifying both results.
Jet Tables example
This separate template-data example defines a required numeric customer_id input. The standalone customer lookup uses the actual table identifier shown by Jet Tables and returns customer 5, Ada Gazey.

Verify
Every returned row should have the requested customer ID. An empty result can be valid if that customer has no orders.

This empty-result screenshot uses the ticket/customer join example, rather than the standalone lookup above.
Bind the saved input to an appropriate app value when using the query in a component. A filter is not a substitute for permissions.
For editor controls, see SQL Query Builder. For existing queries using older input syntax, see Write and test a SQL query.
Was this helpful?