title: auto update column in mysql
body: <p>Currently I build the database for my next project however My database include discussions, posts and some other table</p>
  
  <p>discussions table </p>
  
  <pre><code>id | user_id | title | comments_count | replies_count
  </code></pre>
  
  <p>posts table</p>
  
  <pre><code>id | user_id | content | type
  </code></pre>
  
  <p>type in the posts table may be comment,discussion of reply
  I want comments_count column in discussions table to be auto refer and auto select the count of posts that have the type comment and I want same thing for replies_count.</p>
  
  <p>If this is not possible can help me to auto update the comments and replies count columns automatically using Triggers or events</p>
  
  <p>I hope you can help me</p>
  
  <p>Thanks :)</p>