cross-database query error [SOLVED]
Posted: Wed May 31, 2006 5:14 pm
I'm trying a query that pulls info from 2 separate mysql databases that are located on the same server but have different users & passwords. The query works on my local server, where the 2 db's have the same login information, but not on the server where the login information is not equal.
My query looks like this:
$rstestboth = mysql_query("SELECT l.field1, a.field2 FROM db1.table1 l LEFT OUTER JOIN db2.table2 a ON l.field2 = a.field3") or die(mysql_error());
$row_rstestboth = mysql_fetch_assoc($rstestboth);
$totalRows_rstestboth = mysql_num_rows($rstestboth);
The error that I get is: select command denied to user: 'auser@localhost' for table 'table1'
which makes sense to me because table1 is in the db with 'buser@localhost' as it's login. Can I make this query work without having the same user/pw for both dbs?
My query looks like this:
$rstestboth = mysql_query("SELECT l.field1, a.field2 FROM db1.table1 l LEFT OUTER JOIN db2.table2 a ON l.field2 = a.field3") or die(mysql_error());
$row_rstestboth = mysql_fetch_assoc($rstestboth);
$totalRows_rstestboth = mysql_num_rows($rstestboth);
The error that I get is: select command denied to user: 'auser@localhost' for table 'table1'
which makes sense to me because table1 is in the db with 'buser@localhost' as it's login. Can I make this query work without having the same user/pw for both dbs?