Re: Query 2 MySQL databases in 1 statement
- From: Snef <s.franke@xxxxxxxxxx>
- Date: Wed, 26 Jul 2006 22:53:16 +0200
mootmail-googlegroups@xxxxxxxxx wrote:
noor.rahman@xxxxxxxxx wrote:I assume that they need to be in the same MySQL?I was wondering how it may be possible to query 2 MySQL databases using
one query statement from PHP.
For instance: SELECT database1.tableA.field1 UNION
database2.tableB.field2.
My concern is, when connecting to MySQL (or sending a query), I only
specify 1 database connection resource ID. How does that play out when
connecting to 2 databases?
Thanks.
As I understand it, the database you specify when connecting to mysql
is your default database. For example, if you connect using "db1",
then to query that database, you can just use "SELECT * FROM table1"
which, because of your default database, is equivalent to "SELECT *
FROM db1.table1". You are still able to access other databases by
fully-qualifying the names, so even if "db1" is your default database,
you can still do something like "SELECT * FROM db2.table2".
.
- Follow-Ups:
- Re: Query 2 MySQL databases in 1 statement
- From: Tony Marston
- Re: Query 2 MySQL databases in 1 statement
- References:
- Query 2 MySQL databases in 1 statement
- From: noor.rahman@xxxxxxxxx
- Re: Query 2 MySQL databases in 1 statement
- From: mootmail-googlegroups
- Query 2 MySQL databases in 1 statement
- Prev by Date: Re: HELP - sure is a piece of cake for you
- Next by Date: Re: phpMailer error
- Previous by thread: Re: Query 2 MySQL databases in 1 statement
- Next by thread: Re: Query 2 MySQL databases in 1 statement
- Index(es):
Relevant Pages
|