List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:July 26 1999 6:21pm
Subject:Re: How to UNION in MySQL ?
View as plain text  
Janos Koppany wrote:
> 
> Hi,
> 
> with some databases I can select from multiply databases with UNION like
> 
>     SELECT      db1.foo .....
>     UNION
>     SELECT     db2.foo ....
>     ....
>     ORDER BY 1
> 
> Is there any way with MySQL to "merge" the db1.foo and db2.foo tables,
> where the foo table structure is exactly identical in both databases.
> In my application sometimes I just would see the db1.foo, or sometimes
> the unions of db1.foo, db2.foo, .... , dbN.foo.
> 
> Thanks
> 
> Janos

Hi Janos

Yes, but you have to use a temporary table for this like:
1) CREATE TABLE tmpxxxx (foo ....);
2) INSERT INTO tmpxxxx SELECT db1.foo .....;
3) INSERT INTO tmpxxxx SELECT db2.foo .... ;
4) SELECT * FROM tmpxxxx WHERE ... ORDER BY l;

Tschau
Christian

Thread
How to UNION in MySQL ?Janos Koppany22 Jul
  • How to UNION in MySQL ?sinisa22 Jul
  • Re: How to UNION in MySQL ?Christian Mack26 Jul