cyberRobot Posted December 7, 2016 Share Posted December 7, 2016 When querying tables that are stored in different databases, I normally establish separate database connections, run separate queries, and combine the results in PHP. However, it appears that you can connect to one database and run a joined query on both databases, as long as the login credentials work for both databases. With that said, does anyone know of an issue with writing a query like the one below? SELECT alias1.columnName1, alias2.columnName2 FROM database1.table1 AS alias1 LEFT JOIN database2.table2 AS alias2 ON ... Note that I wouldn't use names like database1, alias1, etc. And you can ignore the "..." in the ON clause. Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted December 7, 2016 Solution Share Posted December 7, 2016 (edited) However, it appears that you can connect to one database and run a joined query on both databases, as long as the login credentials work for both databases. Yes, that's OK. So long as they are both on the same server. The connection is to the server. And, as you said, you have privileges to access all databases in the query. Edited December 7, 2016 by Barand Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted December 8, 2016 Author Share Posted December 8, 2016 Thanks Barand! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.