title: using arraylist inside mysql select statement
body: <p>I have a login <code>arraylist</code> where i have stored users loginid using following mysql query</p>
  
  <p>Code:</p>
  
  <pre><code>query = "select LoginID from issuedeposit id where id.DueDate &lt; CURDATE()";
  
      result = statement.executeQuery(query);
  
      while(result.next())
      {
          String loginid = result.getString(1);
          loginarray.add(loginid);
      }
  </code></pre>
  
  <p>now I want to use the loginid values stored in the <code>above arraylist</code> to fetch users emailid form <code>other</code> table. I am using following query</p>
  
  <p>Code:</p>
  
  <pre><code> for(int i=0;i&lt;=loginarray.size();i++)
      {
  
          res = statement1.executeQuery("select EmailID form studentaccount sa where sa.LoginID = '"+ loginarray.get(i) +"' ");
  
          String email = res.getString(1);
          emailarray.add(email);       
  
      }
  </code></pre>
  
  <p>but am getting error in the above query. So have i correctly used the <code>for loop</code> or it should be used inside the query...?
   I am using JDBC and MySql</p>