@@ -56,7 +56,9 @@ When you run a query from the SQL editor, Metabase sends the query to your datab
## How Metabase executes SQL variables
When your query includes a SQL variable, the `{% raw %}{{#5}}{% endraw %}` tag will be substituted with the SQL query of the referenced question or model, surrounded by parentheses.
When you run a query that includes a [variable][variable-gloss], the query will be executed by replacing the `{% raw %}{{ variable_name_or_id }}{% endraw %}` tag with the SQL query of the referenced question or model.
This means that your main query must be aware of all the tables that your variable is pointing to, otherwise you'll get a SQL syntax error. For example, if your main query uses the `Products` table, but your variable points to a query that uses the `Orders` table, you'll need to include a join to `Orders` in your main query.
For an example, see the documentation on [Referencing models and saved questions in SQL queries](../users-guide/referencing-saved-questions-in-queries.html).