MySQL Forums
Forum List  »  PHP

Re: Query from multiple databases
Posted by: Davor Ergotic
Date: April 22, 2012 01:26PM

Tx all for reply but I found a solution.
After reading about 50 different articles on the web I found the solution.

This is the code:
$sql = "SELECT p1.column1, p1.column2, p2.column1, p3.column1, p3.column2 FROM (database1.table1 p1 LEFT OUTER JOIN $database2.table1 p2 ON = LEFT OUTER JOIN database1.table2 p3 on = WHERE p1.column3 = 'something' ";

And the thing is that you must connect with the user which has privileges to all databases you want to use.
So I used:
mysql_connect('localhost', 'username', 'password');

I didn't select database!! Just connected to the MySQL server!

Anyway, thx to all!!!

Options: ReplyQuote

Written By
Re: Query from multiple databases
April 22, 2012 01:26PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.