title: Update table based on column from other table w/ on conflict
body: <p>I have two tables in Postgres db.</p>
  <p><strong>Table A</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>user</th>
  <th>quantity</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>mike</td>
  <td>100</td>
  </tr>
  <tr>
  <td>bob</td>
  <td>200</td>
  </tr>
  <tr>
  <td>alice</td>
  <td>50</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong>Table B</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>group</th>
  <th>user</th>
  <th>quantity</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>ace</td>
  <td>mike</td>
  <td>10</td>
  </tr>
  <tr>
  <td>beta</td>
  <td>mike</td>
  <td>15</td>
  </tr>
  <tr>
  <td>ace</td>
  <td>bob</td>
  <td>2</td>
  </tr>
  <tr>
  <td>omega</td>
  <td>bob</td>
  <td>15</td>
  </tr>
  <tr>
  <td>omega</td>
  <td>alice</td>
  <td>25</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I want to update table b and set quantity equal to table a's quantity * 0.5 joined on username WHERE table b group = xyz.  If a user does not exist in table b, I need to create it with group xyz, username, table a's quantity * 0.5.</p>
  <p>I kind of have something here, but it doesn't handle when user does not exist in tableb and I'm not sure it is correct syntax for postgres.</p>
  <pre><code>update tablea
  set quantity = tableb.quantity * 0.5
  from tableb
  where tablea.username = tableb.username
  and tablea.group = ace
  </code></pre>