title: How to get matching rows from two tables in SQL, without repeated calls from java
body: <p>I have to read a set of rows from a table(say A) containing a unique id for each row (say id_value).</p>
  
  <p>Now using this id_value i have to get rows from another table (say B).</p>
  
  <p>i am using java so my code is:</p>
  
  <pre><code>ResultSet rs= [ Code to get rows from table A ] ;
  
  while(rs.next())
  {
  ResultSet rs2= [Code to get rows from table B using the id_value from table A using rs.getString("id_value");]; 
  }
  </code></pre>
  
  <p>The above query if ofcourse slow as the number of rows can be more than 500 at a time in table A. </p>
  
  <p>Does anybody knows a better and fast solution to this problem or how to do this in a single query ??</p>