title: ON DUPLICATE KEY: multi-column unique constraint
body: <p>Right now I have:</p>
  
  <pre><code>INSERT INTO mytable (a,b,c,d) VALUES(1,2,3,4)
    ON DUPLICATE KEY UPDATE c=VALUES(c),d=VALUES(d)
  </code></pre>
  
  <p>which works if <code>a</code> or <code>b</code> are <code>UNIQUE</code> keys...</p>
  
  <p>But now I want to UPDATE only when another row with the pair (a,b) doesn't exist in the table (otherwise skip insertion).</p>
  
  <p><strong>Basically <code>(a,b)</code> shoud be UNIQUE</strong>, not <code>(a)</code> or <code>(b)</code>, but both connected.</p>
  
  <p>For example these rows would be valid</p>
  
  <pre><code>ID (auto-inc) | a | b |  c  | d
              0 | 5 | 1 | 343 |466
              1 | 5 | 2 | 363 |466
              2 | 5 | 3 | 343 |496
              3 | 7 | 1 | 343 |496
  </code></pre>
  
  <p>Because there's <code>5,1</code>, <code>5,2</code>, <code>5.3</code>, <code>7.1</code> etc.</p>
  
  <p>But row #2 here should be considered duplicate of row #1, so row #1 should be updated:</p>
  
  <pre><code>ID (auto-inc) | a | b |  c  | d
              0 | 5 | 1 | 343 |466
              1 | 5 | 1 | 363 |466
              2 | 5 | 3 | 343 |496
              3 | 7 | 1 | 343 |496
  </code></pre>
  
  <p>Is this possible?</p>