title: MYSQL server - only update value if not null
body: <p>I would like to only update a value if it isn't null or an empty string, but i've tried everything from <code>COALESCE(new_value, old_value)</code> to <code>COALESCE(NullIf(RTrim(new_value),'')old_value)</code>.</p>
  
  <p>I'm completely lost for ideas and I've been browsing the internet for a solution, but I can't find anything that works for me.</p>
  
  <pre><code>$query = "UPDATE Person SET fornavn=COALESCE($escapedFornavn,fornavn), efternavn='$escapedEfternavn', alder='$escapedAlder', email='$escapedEmail', adresse='$escapedAdresse', telefon=$escapedTelefon WHERE brugernavn='$brugernavn'; ";
  </code></pre>
  
  <p>I want the query above to only update each value if the user has typed in a value in a form, if the form is empty it should just use the old value.</p>