|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Andre Matos (andrematos
mineirinho.org)
Date: Fri Nov 21 2008 - 13:12:58 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Sounds interesting, but does the MERGER support complex SELECT
statements and LEFT JOIN?
Andre
On 21-Nov-08, at 1:45 PM, Brent Baisley wrote:
> On Fri, Nov 21, 2008 at 12:44 PM, Andre Matos <andrematos
mineirinho.org
> > wrote:
>> Hello,
>>
>> Let's suppose I have 5 database: db1, db2, db3, db4, and db5. They
>> all have
>> the same structure but different data.
>>
>> I would like perform this select
>>
>> SELECT TaskDoneOn, TaskDoneBy
>> FROM {database}
>> WHERE TaskDoneOn IS NOT NULL
>>
>> and collect the data from all 5 database. However, I would like to
>> avoid
>> doing something like this:
>>
>> SELECT TaskDoneOn, TaskDoneBy
>> FROM db1
>> WHERE TaskDoneOn IS NOT NULL
>> UNION
>> SELECT TaskDoneOn, TaskDoneBy
>> FROM db2
>> WHERE TaskDoneOn IS NOT NULL
>> UNION
>> SELECT TaskDoneOn, TaskDoneBy
>> FROM db3
>> WHERE TaskDoneOn IS NOT NULL
>> UNION
>> SELECT TaskDoneOn, TaskDoneBy
>> FROM db4
>> WHERE TaskDoneOn IS NOT NULL
>> UNION
>> SELECT TaskDoneOn, TaskDoneBy
>> FROM db5
>> WHERE TaskDoneOn IS NOT NULL
>>
>>
>> Today I have 5, but tomorrow I can have 50 and I don't want to
>> forget any
>> database.
>>
>> Thanks for any help.
>>
>> Andre
>
> Create a MERGE table that is all those tables combined. Then you just
> need to do 1 select as if it was one table. Just be sure to update the
> MERGE table description when ever you add a table.
>
> Brent Baisley
--
Dr. André Matos
andrematos
mineirinho.org
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]