I want to have the query dynamically choose which table it looks up against based on a value in a particular row in another table.
I have this query:
SELECT d.name
FROM `database1`.domains AS d
WHERE (SELECT COUNT(u.id) FROM <<d.db_name>>.users u) > 0
I want to use the value of d.db_name as database name. Example: d.db_name = database2
i want this:
SELECT d.name
FROM `database1`.domains AS d
WHERE (SELECT COUNT(u.id) FROM `database2`.users u) > 0