title: UPSERT in MySQL when NOT using Primary Key
body: <p>I've got a large dataset that I want to import into my MySQL database (using Workbench or Sequel Pro).</p>
  
  <p>The issue is that some rows already exist, and I don't want to duplicate them.</p>
  
  <p>My table structure is similar to </p>
  
  <pre><code>| uid  | year | data1 | data2 |
  |------|------|-------|-------|
  | 123  | 2017 | 12345 | abcde |
  | 124  | 2017 | 23453 | abdfe |
  | 124  | 2016 | 23413 | agrfe |
  | 123  | 2016 | 12325 | addde |
  | 101  | 2016 | 12325 | adddf |
  | 112  | 2017 | 12366 | fgdsd |
  | 146  | 2016 | 11111 | adddj |
  </code></pre>
  
  <p>Eg, in the table above:</p>
  
  <p><code>101</code>, <code>2017</code> <em>doesn't</em> exist, so I'd want to insert it along with the <code>year</code> and <code>data1</code>, <code>data2</code></p>
  
  <p><code>123</code>, <code>2017</code> <em>does</em> exist, so I'd want to update <code>data1</code>, <code>data2</code> with given values, where <code>year = 2017</code></p>