title: MySQL Update if exists else insert - On Duplicate Key confusion
body: <p>I want to write a statement to insert into the database if no record is found and update the existing record if it already exists.</p>
  
  <p>My table is like so:</p>
  
  <pre><code>**ID** | Value | UserID | VoteID
     1       10      567      54
     2       19      600      78
  </code></pre>
  
  <p>I want to do the following (written in semi-pseudo):</p>
  
  <pre><code>IF EXISTS (SELECT ID FROM table WHERE UserID = 600 AND VoteID = 78)
    UPDATE table SET Value = 100 WHERE UserID = 600 AND VoteID = 78
  ELSE 
    INSERT INTO table (Value, UserID, VoteID) Values(100, 600, 78)
  </code></pre>
  
  <p>How does one use 'On Duplicate Key' in this situation, it at all? 
  Thanks</p>