How to create a MySql query that uses tables from multiple databases?By Milan Jovanovic on 10/10/18 in
Starting from the version 2.3 you can connect to multiple separate database connections, and you can make tables from each database but at the moment is not unfortunately possible to join them directly.
You could solve this in some of the cases by using the foreign key functionality and configuring table relations, this way you would be able to pull data from one table and show it in another, even if the tables use different databases as the data sources.
If you would like to create a query with JOINs, and the tables are in different databases, but on the same server, you could use a MySQL view that would be generated based on a stored query using the database.table.field syntax, e.g. something like this is described here.
If the servers are physically separated, our suggestion is to create a PHP script that would pull the data from all of the remote databases into a single one, and run scheduled e.g. once per hour. You could then use the generated table to create a wpDataTable based on that.
Read more about our plugin features in the documentation.