title: MySql Table Insert if not exist otherwise update on non-unique columns
body: <p>In a table like this:</p>
  
  <pre><code>ID | user_ID | name     | value
  1  | 36      | order    | {1, 'asc'}
  2  | 36      | colvis   | 0,1,2,4,7
  3  | 36      | colorder | 0,1,2,4,3,5,6,7
  4  | 37      | colvis   | 0,1,2,4,5,7
  </code></pre>
  
  <p>where only ID is unique and AUTO_INCREMENT, I need to INSERT new row for user_ID=36 and colvis='something', if row 'colvis' for that user doesn't exist already, i.e do something like 'INSERT IF NOT EXIST user_ID=x AND name=y ELSE UPDATE' query.</p>
  
  <p>For example, if I have user_ID=36 and name='colorder', it should update row 3, but with user_ID=37 and name='colorder' it should insert new row. Same with user_ID=36 and name='filter', it should insert a new row.</p>
  
  <p>It can be done with</p>
  
  <pre><code>$exist = $sql-&gt;Query("SELECT * FROM test WHERE user_ID = 36 AND name='colvis'");
  if ($exist) {
    //UPDATE
  } else {
    // INSERT
  }
  </code></pre>
  
  <p>But isn't there a one-liner?</p>
  
  <p>I looked at <a href="https://stackoverflow.com/questions/4205181/insert-into-a-mysql-table-or-update-if-exists?rq=1">Insert into a MySQL table or update if exists</a> and  <a href="https://stackoverflow.com/questions/13520361/mysql-procedure-to-create-or-update-a-row-in-a-table">MySQL procedure to create or update a row in a table</a> and <a href="https://stackoverflow.com/questions/14626782/mysql-insert-if-not-exist-two-column-pair-otherwise-update">MySql Insert if not exist two column pair otherwise update</a>, but those are not applicable unless I have 'user_ID' and 'name' columns unique, are they?</p>