Join Tables Across Different Databases

Joining tables in queries across different MySQL databases is possible if you use fully qualified database and table names.

Both databases will need to be on the same server for this to work 😉

SELECT  db1.table1.column1,
FROM    db1.table1 LEFT JOIN db2.table1
            db1.table1.column2 = db2.table1.column2

The example query will pull two columns (column1 from both databases) and display the results of the LEFT JOIN.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: