Query two database

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
dooh
Posts: 30
Joined: Sun 14 Jan 2007 21:11

Query two database

Post by dooh » Tue 23 Dec 2008 20:12

Hi,

Is possible with MySQLDirect 3.5 query two databases?

Thanks

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 24 Dec 2008 09:47

You can do it in several ways: either using two separate MySqlConnection objects for every database, or with one MySqlConnection object (in this case you need to call the ChangeDatabase() method to switch between your databases).

dooh
Posts: 30
Joined: Sun 14 Jan 2007 21:11

Post by dooh » Thu 25 Dec 2008 09:07

maybe my question was not clearly, i mean:

In the same stament query two databases.

Ex:

SELECT db1.tb1.field1, db2.tb1.field2
FROM db1.tb1, db2.tb1.field2

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 25 Dec 2008 12:11

Yes, this functionality is available. You can execute such query:

Code: Select all

SELECT db1.tb1.field1, db2.tb1.field2
FROM db1.tb1, db2.tb1;
db1 and db2 must be located at the same host.

dooh
Posts: 30
Joined: Sun 14 Jan 2007 21:11

Post by dooh » Thu 25 Dec 2008 18:42

Thanks

Shalex

Post Reply