Re: Running a query on multiple databases

2005-05-03 Thread Andrés Villanueva
That's exactly what a join does... join two or more tables as one, but 
you usually define a common field to join the tables by...
If both tables have the same definition and you want to know how to 
display the data of one of them after the other you need to do a:

select * from db1.table1 union select * from db2.table2;
Andrés Villanueva
Mahmoud Badreddine wrote:
Hi,
I would like to run a query on two tables that reside in two distinct 
databases:

select * from db1.table1 join db2.table2;
This lists both tables adjacent to one another rather than in a sequential 
fashion as one would get if both tables came from the same database.
Is there a way to accomplish this task. 

Thank you.
 


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


RE: Running a query on multiple databases

2005-05-03 Thread Jay Blanchard
[snip]
I would like to run a query on two tables that reside in two distinct 
databases:

select * from db1.table1 join db2.table2;

This lists both tables adjacent to one another rather than in a
sequential 
fashion as one would get if both tables came from the same database.
Is there a way to accomplish this task. 
[/snip]

You don't say what version of MySQL, but this would be the expected
behavior. UNION would be a good start... 
http://dev.mysql.com/doc/mysql/en/union.html

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Running a query on multiple databases

2005-05-03 Thread SGreen
Mahmoud Badreddine <[EMAIL PROTECTED]> wrote on 05/03/2005 01:43:55 
PM:

> Hi,
> I would like to run a query on two tables that reside in two distinct 
> databases:
> 
> select * from db1.table1 join db2.table2;
> 
> This lists both tables adjacent to one another rather than in a 
sequential 
> fashion as one would get if both tables came from the same database.
> Is there a way to accomplish this task. 
> 
> Thank you.
> 
> 
> -- 
> -Mahmoud Badreddine

As long as the databases are on the same server and the account you logged 
into mysql with has the appropriate permissions, your statement should 
work. What happens when you try it?

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine