Make mysql query with INNER JOIN between different mysql servers

Asked

Viewed 1,414 times

7

How could you make a query with INNER JOIN between different servers, as exemplified below:

SELECT
    serverA.clinte AS CLIENTE,
     serverB.enderecoCliente AS ENDERECO
FROM
    127.0.0.1.dbo.cliente AS serverA 
    INNER JOIN 192.168.0.1.dbo.clientes AS serverB 
    ON serverA.cli_id = serverB.cli_id
  • 1

    see documentation. https://dev.mysql.com/doc/refman/5.6/en/federated-description.html

1 answer

13


You need to specify the full path table; if it is on another server, you must specify not only the server but also bank and schematic:

[server].[database].[schema].[table]

Getting something like this:

SELECT
    tabelaServerA.clinte AS CLIENTE,
    tabelaServerB.enderecoCliente AS ENDERECO
FROM
    [127.0.0.1].dbo.schemaDaTabelaCliente.cliente AS tabelaServerA 
INNER JOIN 
    [192.168.0.1].dbo.schemaDaTabelaClientes.clientes AS tabelaServerB 
ON 
    tabelaServerA.cli_id = tabelaServerB.cli_id

Browser other questions tagged

You are not signed in. Login or sign up in order to post.