Solved

ResultSet Concatenation?

Posted on 2002-03-28
7
394 Views
Last Modified: 2008-03-03
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.  
0
Comment
Question by:jerrykovach
7 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 6903160
Select Server as Server_name, Browser as Browser_name
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


...
0
 

Author Comment

by:jerrykovach
ID: 6903255
I wish this solution would work but mySQL doesn't support the union command.  
0
 
LVL 5

Expert Comment

by:kelfink
ID: 6903455
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.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 1

Expert Comment

by:Moondancer
ID: 6912965
Has this helped you or is more needed?
Moondancer - EE Moderator
0
 

Accepted Solution

by:
pothuganti_srinivas earned 200 total points
ID: 7073109
One approach is to have a disconnected result set(your own implementation of IResultSet)which has a method to merge the 2 resultsets. For a implementation of ResultSet check  - http://developer.java.sun.com/developer/technicalArticles/javaserverpages/cachedrowset/

0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7073158
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
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7082225
Zero response, finalized by Moondancer - EE Moderator
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 86
backtracking recursion  code 19 57
servlet example 17 29
Is there a simpler dropbox system? 10 18
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question