Insert variable into SQL statment

Lets say I have a page parameter which is an orderID.
Now, I’d like to use that orderID in a custom SQL query. How would I do that?

Using variables works with the no code SQL Statements, but I am unable to insert them into the custom SQL statements. I need to run custom statements as my DB structure is complex and requires complicated queries where I would need to insert the variable

Hi!

The solution may vary depending on where you are using your custom SQL query.

Usually, you have your custom SQL query saved inside your data source on the Data tab, next to collections. While in the SQL builder, you can set up inputs on the bottom part and then use them via the “insert input” button in your query. Here’s an example from one of my custom SQL collections:

Then I have a page with a “sql_input” page param and a table with an applied filter based on that param:

The same logic should be possible to apply to “Load Data” queries of your page.

If this doesn’t help — drop us a message through chat on the bottom right corner, we will help!