If the two databases are on the same server, you can use joins to select
data from multiple databases.

For instance:
Database 1, Table A:
--------------------
| id     | name    |
--------------------
| 1      | George  |
| 2      | Mark    |
| 3      | Harry   |
--------------------

Database 2, Table A:
--------------------
| id     | name    |
--------------------
| 1      | Bill    |
| 2      | Henry   |
| 3      | Ford    |
--------------------

You can:
SELECT a.name as db1Name, b.name as db2Name FROM Database1.TableA a LEFT
JOIN Database2.TableA b ON a.id=b.id;

Now you'll get:

-----------------------
| db1Name  | db2Name  |
-----------------------
| George   | Bill     |
| Mark     | Henry    |
| Harry    | Ford     |
-----------------------

Hope this helps.

- Jonathan


-----Original Message-----
From: Andy [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 04, 2002 5:50 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] How to querry two db in a single statement?


Hi there,

I would like to make a querry on 2 db. There is info in tables I would like
to compare.

As I know, there has first to be a conect on the db before the querry. But
how to do this on 2 db??

Thanx for any help.

Andy



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to