Sub-Queries: Re-Use Queries in Other Queries
You can re-use a Query inside another one, just like calling functions in your code.
This feature uses the QueryRun DataSource.
Example in VisualQuery
As you'll see in the image below, the QueryRun DataSource actually runs another query and re-uses it.
Watch this video for a walkthrough to learn how to use it yourself.
Checklist to Use Sub-Queries
In many cases you'll have sub-queries which expect parameters.
You could assume that they come from the URL like
[QueryString:Id] but when re-using the query it's better to pass it through the parameters because it will give the caller more control over what parameters are used. In the above example, it's better to do this:
- The sub-query would use
[Params:Id]to use the Params-ID
- The caller would then set
Params:Id=[QueryString:Id]or anything else as needed
- Introduced in 2sxc 10.24