This seems like it should be simple and doable but I'm not smart. I'm trying to sum up the count of hosts across multiple databases on the same server with a single query. The databases to sum up the host count are themselves derived from a query.
get a list of databases:
mysql> select name from db1.companies where status = 'active';
+---------------------+
| name |
+---------------------+
| companyA |
| companyB |
| companyC |
...
Get the total sum of the host count from each database:
SUM(
select count(id) from companyA.hosts
select count(id) from companyB.hosts
select count(id) from companyC.hosts
...
)