title: MySQL conditional insert or update based on date
body: <p>I'm trying to do something like:</p>
  
  <pre><code>IF EXISTS(SELECT * FROM weatherbyday WHERE DATE(DateTime) = CURDATE()) 
  THEN update weatherbyday 
  SET  
  TempMin='[th0temp-dmin]', 
  TempMax='[th0temp-dmax]'
  WHERE DATE(DateTime) = CURDATE()
  ELSE INSERT INTO weatherbyday (DateTime, TempMin, TempMax ) VALUES ('[YYYY]-[MM]-[DD] [hh]:[mm]:[ss]', '[th0temp-dmin]','[th0temp-dmax]' )
  </code></pre>
  
  <p>but IF can't be used in this syntax.</p>
  
  <p>There are plenty of answers to this sort of problem conditional on duplicate keys, but I want to use the date as a condition, which can't be a key. </p>
  
  <p>Can anyone provide an elegant answer?</p>
  
  <p>Thank you
  David</p>