title: MySQL Update or Insert when columns match
body: <p>I currently have the problem that i need to either insert or update a row when two columns(event_id and question_id) have the same value as another row
  For example i have event 1 and question 2 of the event
  Now when there is already an inserted entry it should update this one to the new value (selected)</p>
  
  <p>But the syntax I tryed isn't working.Could you please help me with this problem?</p>
  
  <pre><code>IF EXISTS (SELECT id as @info FROM votes WHERE event_id = 1 AND question_id = 2)
    UPDATE votes SET selected='1,2,3' WHERE id=@info
  ELSE
    INSERT INTO `votes` (`id`, `event_id`, `question_id`, `selected`, `user_id`) VALUES (NULL,      1, 2, 3, 4)
  </code></pre>