title: mysql trigger on insert many to many
body: <p>I have two tables with many to many relationship.
  The tables are </p>
  
  <pre><code>table user
  idUser
  name
  
  table right
  idRight
  type
  
  table user_has_right
  idUser
  idRight
  </code></pre>
  
  <p>When I insert a user with the rights I want him to have,
  obviously the middle table (user_has_right) must have some inserts
  too. Let's say I want to insert the user with id = 1 and name = 'test'
  and right = 'boss' , where boss is already a row in table right with id = 1 . 
  The middle table must have an insert of (1,1).
  I know how to do this programmatically, but can this be done with trigger on insert?</p>
  
  <p>Thank you.</p>
  
  <p>//The problem I'm facing is how to find the idRight for type 'boss'. Maybe a nested select inside the trigger? </p>
  
  <p>//Is this task even possible? </p>