0

I have a request that I should do the joint of 2 tables, 2 tables belong to different databases, how to prepare, execute and display the results, knowing that the first connection is $db1 and 2nd is $db, and preparation is made for example,here is my code:

 $db=new PDO('mysql:host=localhost;dbname=service','root','');
$db1=new PDO('mysql:host=localhost;dbname=service1','root','');
$query = 'SELECT * FROM db1.table1 JOIN db2.table2 ... WHERE ... id = ?';
5
  • Thanks, but how i can write a prepare request, here my code : $sql = $db1->prepare('update myusers a inner join "'.$db.'".myusers b on (a.ID=b.ID) set a.fid=b.fid where a.ID = 1 and b.ID = 1'); $sql->execute(); Commented Mar 29, 2016 at 11:09
  • Just write it usual way. Commented Mar 29, 2016 at 11:12
  • @YourCommonSense, sorry can you exlain to me more. Commented Mar 29, 2016 at 11:15
  • There is absolutely no difference from a regular prepared statement. Commented Mar 29, 2016 at 11:18
  • thanks, it's resolved. Commented Mar 29, 2016 at 11:20

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.