This topic is locked

Query with 2 databases

10/17/2018 8:03:22 AM
PHPRunner General questions
S
sol author

I use PHPrunner Enterprise because I have 2 databases in use for the same project.
In the database tables view I can "connect" both databases. But in the query, I can not add a table from the other database.

As I have foreignkey fields in the first database relating to tables in the other database, I should be able to use both databases in the query.

Is there a way to do so?

jadachDevClub member 10/17/2018

You need to set up proper permissions on the database side.

admin 10/18/2018

This is how you can query multiple databases in a single query (MySQL syntax but should be similar in SQL Server):

SELECT

mydatabase1.tblUsers.UserID,

mydatabse2.tblUsers.UserID

FROM

mydatabase1.tblUsers

INNER JOIN mydatabase2.tblUsers

ON mydatabase1.tblUsers.UserID = mydatabase2.tblUsers.UserID


More info:

https://stackoverflow.com/questions/674115/select-columns-across-different-databases