title: How to insert a scanned value on a mySQL table?
body: <p>I have an issue on how to insert a value from another table into a new one. I have the following code: </p>
  
  <pre><code>Scanner scanner1 = new Scanner(System.in);
  java.sql.Statement st = conn.createStatement();
  ResultSet res = st.executeQuery("SELECT * FROM flight");    
  int f_id = scanner.nextInt();  
  int air_id = scanner.nextInt();
            while (res.next()) {
               if (Integer.parseInt(res.getString("air_id")) == air_id &amp;&amp; Integer.parseInt(res.getString("f_id")) == f_id) {
                  if (Integer.parseInt(res.getString("f_status_f_id_s")) &gt; 0) {
                        System.out.println("You can reserve");
                        stmt=(Statement) conn.createStatement();
                        stmt.execute("SET FOREIGN_KEY_CHECKS=0");
                              String query1= "INSERT INTO reservations" +" VALUES(1,6/6/2020,)"+air_id+"(..,..,;
                              stmt.executeUpdate(query1);
  </code></pre>
  
  <p>To be more specific on the line <code>String query1= "INSERT INTO reservations" +" VALUES(1,6/6/2020,)"+air_id+"(..,..,;</code> I want the air_id to be the value I scanned before such as f_id. Is this the right syntax way to do it? </p>