Bhavesh Gangani Bhavesh Gangani - 1 year ago 146
MySQL Question

Select two or multiple tables from different databases

how to use two tables in a single query, which are in different databases, means,

SELECT,,, table2.telephone
FROM table1, table2

are in separate database.

Answer Source

You can do cross-database joins, no problem. Simply prefix your table name with database name.

SELECT,,, t2.telephone
FROM db1.table1 t1
INNER JOIN db2.table2 t2 on =;

Be wary of permissions, though. If a user doesn't have access to one of the databases, this select will fail.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download