wood burning stoves 2.0*
The moose likes JDBC and the fly likes merging result sets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "merging result sets" Watch "merging result sets" New topic

merging result sets

Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
Hello Friends i have a problem:
I have to retrieve data from two tables each table contains two fields(for simplicity otherwise there are more) ie date and name. I have to merge the data from two result set and display the data sorted in order of date.
Like this

As you can see it is possible that a table may not contain any entry for particular tdate in that case that field should be left blank.
Any suggestions.
[ December 02, 2002: Message edited by: Prakash Dwivedi ]

Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Braj Prasad

Joined: Apr 08, 2002
Posts: 16
Write a single query joining the two tables, and do an outer join for the fields that can be null.
Once, you get the result set, check for it being NULL , by using the method ResultSet.wasNull(), after retreiving the value:
String lStrTemp=ResultSet.getString(ColumnName);
It is sorta covered in the JavaRanch Style Guide.
subject: merging result sets
Similar Threads
Oracle date-time fields
any good hql query for this scenario?
Problem with date
problem while insert date data in mysql
Seeking help on a complex SQL I reckon, wish get a simple one from answer