title: How to compare the values of two resultset in java
body: <p>I have two tables. And these tables have the same schema consisting of userid, username. I want to check is there any common <code>username</code> in <code>table1</code> and <code>table2</code>.</p>
  
  <pre><code> rs1 = statement.executeQuery("select username from table1")
   rs2 = statement.executeQuery("select username from table2")
  </code></pre>
  
  <p>My logic is:</p>
  
  <ul>
  <li><code>while(rs1.next())</code></li>
  <li>compare the value of <code>rs1</code> with every value of <code>rs2</code>.</li>
  <li><code>If</code> there match found print one of the value <code>else</code> print both the values.</li>
  </ul>
  
  <p>Is there a way to achieve this in  java... Please anyone help me ... Thanks... </p>