title: Using variables in where clause of SQL statement in JAVA
body: <p>I want to select some rows from my database based on the values stored in my variables (<code>supp_rec</code> array). I have used tips on similar previous post/question. However, I am still having some error messages. The code snippet is below: </p>
  
  <pre><code>waiting_time = dbMngr.runQuery( "SELECT " + "ExpectedWaitingTime" + " FROM Student" +     "where deptID = '" + supp_rec[1] + "' and weight = '" + supp_rec[2] + "'");
  prob = PoisonModel(Phase3GUI.existence_time -     Long.parseLong(waiting_time[0]),2,Phase3GUI.existence_time);
  if (prob &gt; 0.5)
   {
      dbMngr.execUpdate( "DELETE " + " FROM Student" + "where deptID NOT IN" + supp_rec[1] + " and weight NOT IN" + supp_rec[2]);
   }+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  </code></pre>
  
  <p>The error message is below:</p>
  
  <pre><code>com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'deptID NOT IN1 and weight NOT IN8' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  
  com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= '1' and weight = '8'' at line 1
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  </code></pre>
  
  <p>Please I will appreciate any help on how to solve these errors. Thank you.</p>