• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compare Two Column

 
Rashmi Trivedi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This appears to be related to Databases and is not specific to Servlets. I'm moving it to the JDBC forum.
Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic