title: INSERT INTO USING INNER JOIN in Java
body: <p>Table Employer</p>
  
  <pre><code>CREATE TABLE "Employer" ("employerID" INTEGER PRIMARY KEY  NOT NULL ,
  "name" CHAR,
  "industry" CHAR,
  "contact1" CHAR,
  "contact2" CHAR,
  "email" CHAR,
  "website" CHAR,
  "facts" CHAR,
  "phone" VACHAR)
  </code></pre>
  
  <p>Table Job</p>
  
  <pre><code>CREATE TABLE "Job" ("jobID" INTEGER PRIMARY KEY  NOT NULL ,
  "employerID" INTEGER,
  "title" CHAR,
  "description" CHAR,
  "type" CHAR,"salary" CHAR,
  "benefits" CHAR,
  "vacancies" INTEGER,
  "closing" CHAR,
  "requirement" CHAR,
  "placement" BOOL,
  "applyTo" CHAR,
  "status" CHAR,
  "posted" CHAR, 
  "location" CHAR)
  
   try {  
      //String sqlStm = "INSERT INTO Job (employerID,title,description,type,salary,benefits,vacancies,closing,requirement,placement,applyTo,status,posted,location) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?) INNER JOIN Employer ON Job.employerID = Employer.employerID"; 
     String sqlStm = "SET @SELECTED_ID = (SELECT employerID FROM Employer WHERE name = '"+comboEmployer.getSelectedItem().toString()+"') INSERT INTO Job (employerID,title,description,type,salary,benefits,vacancies,closing,requirement,placement,applyTo,status,posted,location)VALUES (@SELECTED_ID,?,?,?,?,?,?,?,?,?,?,?,?,?)";
         pst = conn.prepareStatement(sqlStm);
  
      pst.setString(2,txtTitle.getText());
       pst.setString(3,areaDescription.getText());
        pst.setString(4,comboType.getSelectedItem().toString());
         pst.setString(5,txtSalary.getText());
          pst.setString(6,areaBenefits.getText());
           pst.setString(7,txtVac.getText());
            pst.setString(8,txtDate.getDateFormatString().toString());
             pst.setString(9,areaReq.getText());
              pst.setString(10,comboPlace.getSelectedItem().toString());
               pst.setString(11,txtWeb.getText());
                pst.setString(12,comboStatus.getSelectedItem().toString());
                 pst.setString(13,"01-01-2013");
                  pst.setString(14,txtLoc.getText());
                     pst.executeUpdate();
     } catch (Exception e) {
          JOptionPane.showMessageDialog(null,e);
      } finally {
          try {
              rs.close();
              pst.close();
          } catch (Exception e) {
          }
      }  
  }
  </code></pre>
  
  <p>I am trying to allow users to add jobs to the system and a form requires them to pick employers from <code>Employer</code> table. I am not sure how to relate the chosen employer from <code>JCombobox</code> to the Job. i.e. employerID in <code>Job</code> table should be matched to the employerID of <code>employer</code> table. Ive managed to do the <code>Select</code> statement,</p>
  
  <pre><code> sql = "SELECT Job.jobID as 'Job ID', Employer.name as'Company', Job.title as 'Role', Job.type as 'Type', Job.closing as 'Closing Date' FROM Job INNER JOIN Employer ON Job.employerID=Employer.employerID ORDER BY Employer.name";
  </code></pre>
  
  <p>but not sure how to <code>INSERT</code> into sqlite manager. Heres the form : <img src="https://i.stack.imgur.com/8r5RS.png" alt="enter image description here"></p>