2

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?

jjclarkson
  • 5,772
  • 5
  • 39
  • 62

1 Answers1

2

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

Community
  • 1
  • 1
Alix Axel
  • 147,060
  • 89
  • 388
  • 491