I have an SQL Query I need to run at multiple sites, the query will be the same except for the "Site-ID" The site id is stored in another table on each database, so I figure it would be easier to automate this and write the query to grab the correct siteid right in the where clause instead of changing the query 20 times. 

My query is:

```
Select *
from customers
where bactive = 'true' and siteid = 'Site1'

```

The Site is stored in the table "Account" So I figured I could do something like this:

```
select *
from customers
where bactive = 'true' and siteid = database.dbo.accounts.siteid

```

This didn't work.

Any help is appreciated.