title: Update Composite Key On Duplicate Key
body: <p>I need to update new row just if both: <code>date='$dat'</code> and <code>empId='$who</code> ( as composite key ) . But insert if one of them or both differ:</p>
  
  <pre><code>$sql= "INSERT INTO history 
         SET endtimestamp='$now',end='$signature',date='$dat',empId='$who' 
         ON DUPLICATE KEY UPDATE endtimestamp='$now',end='$signature'";
  </code></pre>