Join Two Tables From Different Databases On The Same Server

Posted By Weston Ganger

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:

Article Topic:Software Development - Web Development

Date:March 22, 2015