title: MySQL Update set Value only if flag = 0
body: <p>I have this Query:</p>
  
  <pre><code>INSERT INTO `items` (`id`,`image`)
     VALUES(112,'asdf.jpg'),(113,'foobar.png')
  ON DUPLICATE KEY UPDATE
    `id`VALUES(`id`),
    `image` = IF(image_uploaded = 0, VALUES(`image`),image);
  </code></pre>
  
  <p>The worse: its properly working but not as i want.</p>
  
  <p>What i want: The images should only be updated if the field "image_uploaded" is set to 0.</p>
  
  <p>Any ideas?</p>
  
  <p>The Background: I have a DB-Table with data. Now each night a cronjob calls an API-Fn to get new Data from another DB and write it down to my table. This function is getting all items from the second DB so its currently just overwriting my existing data. Now my Application allows changes on data i got from the 2nd DB and overwrites the changes in my own Table. So the Problem is: I need the ability to edit Data via my App AND update Data via API without colliding. The User may change the "image" but all other things should be updated from the 2nd DB. The Image should only be overwritten if it wasn't uploaded manually.</p>