Using a variable to select a database

When writing a question in SQL, if it possible to use a variable to determine which database gets used for the question?

For example, if I have a database "US Customers" and one "EU Customers", can both contain tables called sales, can I do something in a question so that a variable chooses the database?

select *
from case when {{var}} = "US" then Sales (US customers) else Sales (EU Customers) end

rather than having to create two copies of the same question, just using the different databases?

Hi @jtemplin
No, the database is selected outside of any parameters.
But you can use Snippets if it is just basic queries:

You can read the referenced issues here, which will explain some of the problems and the security concerns related to allowing changing database via a variable:

1 Like

Thanks very much! :pray: