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 * FROM
db2.sometableWHERE 1
views:
18answers:
3
A:
I think yes - have you tried it? and do you have access privileges to the 2nd db?
steelbytes
2010-04-07 01:42:56
+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
2010-04-07 01:44:22
A:
its possible just reference the db name in your query like select * from db.table
Levi Hackwith
2010-04-07 01:44:24