Jump to content

Multiple database connections with the same table names


chad.portman

Recommended Posts

Once a connection is open it stays open until it's closed or the script finishes.This will also help:http://stackoverflow.com/questions/3686014/how-to-select-fields-from-different-dbs-with-the-same-table-and-field-name

Edited by niche
Link to comment
Share on other sites

Thank you the link helped a lot. But I guess I should be more clear I was saying Databases earlier. I meant to say I have Multiple Database Engines connect that have the same names of their respective Databases, Tables, and column names. And was wondering if you could link between the database engines.

Edited by chad.portman
Link to comment
Share on other sites

If you're dealing with different servers you will have to pull the information from the databases independently from each other. MySQL only works inside its own server.

 

 

If you're dealing with multiple databases on the same server you can get content from the tables by prepending the database's name to the table name.

Example:

SELECT t1.field1, t1.field2, t2.field1 FROM database1.table1 AS t1, database2.table1 AS t2 WHERE t1.id = t2.id
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...