How to use NOT IN with data from another server in PHP

1

I've set up a table with Data that no should be fetched, I'll call it here Table . The data that was in this table are these:

|Tabela_Not|
  Londres
  Tóquio
  Paris

And I applied this Query to do searches by dropping the Table_Not items:

SELECT * FROM BancoANoServidor1.registros WHERE Papel NOT IN (SELECT Papel FROM BancoANoServidor1.Tabela_Not);

As you can see in Query, the two tables are on the same database / server, my question is, what table records would I like to do this query is on another server > BancoBNo.Server2.registers ).

Can you solve this using only Mysql? Or is there another way to solve this in PHP? There is something like:

$Query_not = "SELECT Papel FROM BancoANoServidor1.Tabela_Not";
$result_not = mysqli_query($conecta1, $Query_not);

$Query_return = "SELECT * FROM BancoBNoServidor2.registros WHERE Papel NOT IN ($result_not)";
$return = mysqli_query($conecta2, $Query_return);
    
asked by anonymous 23.02.2018 / 17:34

1 answer

1

You can loop in the first query.

The logic would be something like this:

while $result_not 
$negar = $negar + $result_not["Papel"] + ","

At the end of the loop you'll have the $ variable deny something like: "London, Tokyo, Paris"

Yes, you can use:

$Query_return = "SELECT * FROM BancoBNoServidor2.registros WHERE Papel NOT IN ($negar)";
    
23.02.2018 / 18:09