Join Two Tables From Different Databases On The Same Server

Posted by Weston Ganger on March 22, 2015

Sometimes you have an application with a master/shared database for shared models between applications and your regular application database. Maybe you need to join two tables to search the associations on them. Well heres an example SQL statement that will do such a thing.

**Note: This can only be done when the two databases are on the same server.

SELECT a.userID, b.usersFirstName, b.usersLastName FROM databaseA.TableA a INNER JOIN databaseB.TableB b ON a.userID=b.userID;

Related External Links:

Posted in Web Development and Tagged with sql mysql postgresql 

Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts