Make INNER JOIN on two different bases

1

I have 2 different MySQL databases, I can do a query on a base or another specifying which connection I'm going to use like this:

$result1 = mysql_query($sql1, $banco1);
$result2 = mysql_query($sql2, $banco2);

Now a problem has arisen, I need in the same query to make an INNER JOIN with tables of different banks, is it possible? (something like that)

$sql0 = "SELECT * FROM tabela1_banco1
INNER JOIN id ON tabela2_banco2.id = tabela1_banco1.id_usuario";
$result0 = mysql_query($sql0, $banco1, $banco2);
    
asked by anonymous 24.08.2018 / 16:09

1 answer

0

Yes, it is possible; you just need to reference the banks that the tables belong to:

$sql0 = "SELECT * 
   FROM banco1.tabela
   INNER JOIN banco2.tabela ON banco2.tabela.id = banco1.tabela.id";
    
24.08.2018 / 16:24