title: SQL count variables and write into another table
body: <p>I need to transfer data from karma mod in phpbb to karma in smf.</p>
  
  <p>Phpbb has a table <code>phpbb_karma</code> which is basically a karma log. Important fields we need to focus on are <code>user_id</code> (user which got the karma) and <code>karma_action</code> (positive or negative karma, shown as + or -).</p>
  
  <p>I would need a query to count all the pluses and minuses and then copy the given results for each unique <code>user_id</code> into <code>smf_members</code> table under appropriate <code>id_member</code> (<code>user_id</code> field in smf) and <code>karma_good</code> (all the pluses) and <code>karma_bad</code> (all the minuses).</p>
  
  <p>I think it can be done but I am not SQL expert.</p>