views:

39

answers:

1

I have code that in the connection setup selects the database using mysql_select_db().

$link = mysql_connect('localhost', 'user', 'pass');
mysql_select_db("database1");

Can I later run a query against two databases such as:

SELECT database1.row, database2.row 
FROM database1.table, database2.table 
WHERE database1.row = database2.otherrow

even though "database1" was already selected at first? Or is there a method for unselecting the database?

+2  A: 

You can. Also check this out: How do I construct a cross database query in PHP?

Alix Axel