Tutorial :Access 2nd MySQL db in PHP without mysql_select_db()


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


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.


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


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

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »