title: IF Exists Then Update MySQL
body: <p>I am trying to update a row if its exists, if it does not exist then I want to perform an insert into the table. The picture.id &amp; picture.picturepath are a unique key. I have looked at some examples but I am not sure What I am doing wrong. </p>
  
  <p>I have come across on duplicate key update, not sure if this is relevant to what I am trying to achieve. </p>
  
  <pre><code>Error message: 1064- You have an error in your SQL syntax near 'UPDATE picture SET picture.picturecontent = ipicturecontent WHERE picture.id at line 5"
  
  
      IF EXISTS( SELECT * FROM picture WHERE picture.id = ipictureid 
      AND picture.picturepath = ipicturepath) THEN
  
      UPDATE picture 
      SET picture.picturecontent = ipicturecontent
      WHERE picture.id = ipictureid 
      AND picture.picturepath = ipicturepath
  
      ELSE
  
      INSERT INTO picture (picture.id, picture.picturecontent,picture.picturepath) VALUES (ipictureid, ipicturecontent, ipicturepath)
  </code></pre>