title: How to write query in java to insert data with foreign keys using MySql
body: <pre><code>Table 1 :questions(qid,category,question);  PRIMARY KEY:qid,category  
  Table 2 :choices(ch_id,qid1,category1,choice);  PRIMARY KEY: ch_id  
  </code></pre>
  
  <p>Here qid, ch_id use AUTO_INCREAMENT.  </p>
  
  <p>Sql Query:  </p>
  
  <pre><code>mysql&gt;INSERT INTO choices(qid1,category1,choie)  
  -&gt;SELECT qid,category,'Some Choice'  
  -&gt;FROM questions 
  WHERE qid1=qid AND category1=category;  
  </code></pre>
  
  <p>With this scenario how would I write this code for java with the same query.</p>