PDA

Click to See Complete Forum and Search --> : Multiple Databases


systech44
Mar 11th, 2008, 12:15 AM
Hi,

Is it possible to access data from more than one database at a single time ? I mean with a single connection. Along with this I would like to know how to extract the common names available in 2 different tables in 2 different databases by using a single query. Please help.

Thank you so much.

penagate
Mar 11th, 2008, 12:22 AM
Prefix the table name with the schema name.

mysql> select t1.id, t2.id from test.table1 t1 left join test2.table1 t2 on (t1.id=t2.id);
+----+------+
| id | id |
+----+------+
| 1 | 1 |
| 2 | 2 |
+----+------+
2 rows in set (0.07 sec)

the user account you use to connect will need appropriate permissions in both databases.