This may not be possible ;^)
I'm trying to pull together billing and performance data from separate client dbs. The "core" db has a table like so:
client_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
client_db_name VARCHAR(100),
...
Each client_db has a table, orders
, with columns order_date
and order_total
.
Conceptually, I'd like to be able to use the client_db_name
in a query:
SELECT SUM(order_total) AS sales
FROM {client_db_name}.orders AS o
WHERE o.order_date LIKE '2021%'
Questions:
- is this even possible?
- if so, how would I JOIN this query? What would the
ON
be?
Many thanks!