jerrykovach
asked on
ResultSet Concatenation?
The $epoch_starttime and $epoch_endtime in the following query are variables. I need to generate a ResultSet object from each of the following tables and add the results together into one ResultSet object.
The reason for this is I am working with a third party software and they can only accept one recordset object for processing(charting software). Is it possible to concatenate results from one ResultSet object onto another? If not, how could I go about addressing this problem?
Tables
m2002_01, m2002_02, m2003_03
Query Example
Select Server as Server_name, Browser as Browser_name where starttime > $epoch_starttime and endtime < $epoch_endtime.
The reason for this is I am working with a third party software and they can only accept one recordset object for processing(charting software). Is it possible to concatenate results from one ResultSet object onto another? If not, how could I go about addressing this problem?
Tables
m2002_01, m2002_02, m2003_03
Query Example
Select Server as Server_name, Browser as Browser_name where starttime > $epoch_starttime and endtime < $epoch_endtime.
ASKER
I wish this solution would work but mySQL doesn't support the union command.
If you can upgrade to mySQL 4.0.0, then it has been implemented.
http://www.mysql.com/doc/U/N/UNION.html
If not, then I recommend a temporary table...
Use:
create temporary table temp_m2002
( server_name varchar(20), browser_name varchar(20));
insert into temp_m2002 ( server_name, browser_name)
select server as server_name , browser as browser_name
from m2002_01 where starttime > $epoch_starttime and endtime
< $epoch_endtime;
insert into temp_m2002 ( server_name, browser_name)
select server as server_name , browser as browser_name
from m2002_02 where starttime > $epoch_starttime and endtime
< $epoch_endtime;
insert into temp_m2002 ( server_name, browser_name)
select server as server_name , browser as browser_name
from m2002_03 where starttime > $epoch_starttime and endtime
< $epoch_endtime;
select * from temp_m2002 ;
The select will return the one big result set, containing all selected rows. When the session is closed, the temporary table will drop automatically.
http://www.mysql.com/doc/U/N/UNION.html
If not, then I recommend a temporary table...
Use:
create temporary table temp_m2002
( server_name varchar(20), browser_name varchar(20));
insert into temp_m2002 ( server_name, browser_name)
select server as server_name , browser as browser_name
from m2002_01 where starttime > $epoch_starttime and endtime
< $epoch_endtime;
insert into temp_m2002 ( server_name, browser_name)
select server as server_name , browser as browser_name
from m2002_02 where starttime > $epoch_starttime and endtime
< $epoch_endtime;
insert into temp_m2002 ( server_name, browser_name)
select server as server_name , browser as browser_name
from m2002_03 where starttime > $epoch_starttime and endtime
< $epoch_endtime;
select * from temp_m2002 ;
The select will return the one big result set, containing all selected rows. When the session is closed, the temporary table will drop automatically.
Has this helped you or is more needed?
Moondancer - EE Moderator
Moondancer - EE Moderator
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
jerrykovach -> You last logged in May, 2002, after my request above was posted, and additional information has been added by another expert. Please update and finalize this question.
If no response, expert input please with closing recommendations for me.
Thanks,
Moondancer - EE Moderator
If no response, expert input please with closing recommendations for me.
Thanks,
Moondancer - EE Moderator
Zero response, finalized by Moondancer - EE Moderator
from m2002_01
where starttime > $epoch_starttime and endtime < $epoch_endtime
union
Select Server as Server_name, Browser as Browser_name
from m2002_02
where starttime > $epoch_starttime and endtime < $epoch_endtime
union
Select Server as Server_name, Browser as Browser_name
from m2002_03
where starttime > $epoch_starttime and endtime < $epoch_endtime
...