This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Compare Two Column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Compare Two Column" Watch "Compare Two Column" New topic
Author

Compare Two Column

Rashmi Trivedi
Ranch Hand

Joined: Aug 13, 2001
Posts: 60
Hi Guys
This is what i am trying to do...I have 1 table calledd...User_LOGIN and it has 2 column...one it LOGON1 and LOGON2...i want to compare these two column and find out which record is missing and produce txt file with the missing one...
I have one record which has all the records from column 1 and another record set with all the records from column 2...
now i am struggling as to how do i compare these two record set...
Could you give me some example...as how should i do this...
I do appreciate ur time and consideration...
Regards,
Rashmi
Faisal Khan
Ranch Hand

Joined: Jun 29, 2003
Posts: 285
Rashmi,
I don't think this post is anything to do with Servlets, rather it is SQL. I am not entirely sure, what you are trying to achieve but if its to compare two tables and find out what is missing in one, you can do the following (I am using MySQL):
SELECT t1.col1, t1.col2
FROM table1 t1
LEFT JOIN table2 t2
ON t1.col1 = t2.col1
WHERE t2.col1 IS NULL;
HTH


The secret to creativity is knowing how to hide your sources.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I think you said you were comparing record sets - the results of two queries. The basic algorithm for this goes back to the ancient geeks of mainframe batch days:

End of file (set) can be handled a couple ways. One is to set an impossibly high key so the key comparisions keep working. Another is to add EOF tests to the comparisons: if A Key < B Key or B EOF ...
I wrote a little program that does this logic on any two result sets. You tell it how many columns are involved in the key and make sure those columns are left-most in each row. Pretty cool to compare data or meta-data between two versions of a database.
Was that what you were asking?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

This appears to be related to Databases and is not specific to Servlets. I'm moving it to the JDBC forum.
Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compare Two Column
 
Similar Threads
Radio button value with submit
URLBird find by Hotel or Name
Database Lock(-1)?
nx: All of URLy Bird 1.1.3 read/write lock(2)
Compare operators