Depending on how many records you want to join, it make take a lot of time to do that via code.
If yor're the DBA or the DBA is willing to help you, why don't you try with a linked server??
With a linked server, you can run the query in either of the servers with PHP, so you code will look something like this:
$query = "SELECT a.id_col, b.col, a.other_col
FROM [SERVER1].[your_db].[dbo].your_table
INNER JOIN your_other_table b
ON a.id_col = b.id_col";
That way, you can run your query from either server.
If you're using SQL Server, you can do it like this or with SSMS, like this.
I've never created a linked server in MySQL, but in this link you can find how to do it.
Hope it helps.