title: mysql - Automatically update occurrences in another table
body: <p>I have two tables, one for storing reports of a user, and another for storing users. </p>
  
  <pre><code>1. Report_table
  -----report_id(P)-----user_id--------
          001           user1
          002           user1 
          003           user3
  
  
  2.Users table 
  -------user_id(P)-------no_of_reports
          user1             2
          user2             0
          user3             1 
  </code></pre>
  
  <p>Now whenever a report is inserted in report_table(say report_id:004, user_id: user1), I update both tables like this.</p>
  
  <pre><code>INSERT INTO reports_table VALUES (004,`user1`)
  INSERT INTO users_table  (user_id,no_of_reports) VALUES (`user1`,1)
    ON DUPLICATE KEY UPDATE no_of_reports=no_of_reports+1;
  </code></pre>
  
  <p>Is there a better way of doing this.. 
  Is there a way of <strong>automatically incrementing</strong> the no_of_reports counter when a new report is inserted?</p>