title: How to insert values in table with foreign key using MySQL?
body: <p>I have these two tables just for example:</p>
  
  <pre><code>TAB_TEACHER
  - id_teacher   // primary key, autoincrement
  - name_teacher // a varchar
  
  TAB_STUDENT
  - id_student    // primary key, autoincrement
  - name_student  // a varchar
  - id_teacher_fk // foreign key reference to a teacher (TAB_TEACHER)
  </code></pre>
  
  <p>I want to know how to insert in these two cases:</p>
  
  <p>CASE 1 - INSERT a new Student with an pre-existing TEACHER, so I have to get the foreign key with a teacher name</p>
  
  <p>CASE 2 - INSERT a new Student with a new TEACHER (the teacher I'm creating in the same time I'm creating the student)</p>