title: "replace into" ONLY if new record has a newest timetamp
body: <p>Simply put, I have a MySQL table with 2 fields (idDevice and timestampReported).</p>
  
  <p>Currently I do this to insert a record:</p>
  
  <pre><code>replace into example_lastevent
      SET
      timestampReported =     1523395565, -- april 10 2017
      idDevice=3
  </code></pre>
  
  <p>What I'm trying to do now is modifying this query, so it doesn't update if the previous record has a higher (more recent) timestamp. I tried the following doesn't work</p>
  
  <pre><code>replace into example_lastevent
  SET
  timestampReported = if(timestampReported &gt; 123456, timestampReported,123456) -- 02 Jan 1970 (SHOULD NOT BE EXECUTED)
  idDevice=3
  </code></pre>
  
  <p>Is there a way of doing this?</p>