tags:

views:

18

answers:

3

If I select a db db1 with mysql_select_db() is it possible to access another db db2 in a query? I am looking for something like SELECT * FROMdb2.sometableWHERE 1

A: 

I think yes - have you tried it? and do you have access privileges to the 2nd db?

steelbytes
+1  A: 

That syntax should work perfectly fine. If you want to access a table from another database the syntax is:

SELECT * FROM DatabaseName.TableName WHERE ....

However, this only works if both databases are on the same instance of MySQL.

Kibbee
A: 

its possible just reference the db name in your query like select * from db.table

Levi Hackwith