Use multiple values in Retool Query WHERE statement

October 22, 2024

Here's a quick tip for making SQL queries that involve selecting multiple values from a multi-select component in Retool.

When working with Retool's SQL query language, you can seamlessly blend SQL and JavaScript using double curly braces (Mustache syntax).

This allows you to reference JavaScript values or Retool component instances directly in your SQL queries.

If you're trying to filter results based on multiple values from a multi-select component, named multiselect, here's how to construct a SQL WHERE clause that handles multiple selections:

SELECT * FROM "Table" WHERE category = ANY ({ { multiselect.value } })

This query ensures that the category matches any of the selected values from the multi-select component. This approach makes it simple to dynamically filter data based on user selection, improving flexibility in your Retool apps.

I hope this little tip saves you time in your Retool day-to-day development!

Have a business need or a project in mind?

We help ambitious companies ride the change