title: SQL UPDATE ... SELECT, or leave as is if not found
body: <p>I have a MySQL query that maps Users to Zones according to their location, and the zone boundaries:</p>
  
  <pre class="lang-sql prettyprint-override"><code>UPDATE User u SET u.zoneId = (
     SELECT z.id FROM Zone z
     WHERE ST_Contains(z.boundary, u.location)
     ORDER BY z.level DESC
     LIMIT 1
  );
  </code></pre>
  
  <p>This works fine, although it tries to set <code>zoneId</code> to <code>NULL</code> when no matching Zone is found.</p>
  
  <p>In my domain, a User must always have a Zone, therefore <code>zoneId</code> is <code>NOT NULL</code>. This requirement is enforced when the User is created, but could potentially be broken when the Zone boundaries are redrawn, and the above query is run.</p>
  
  <p>How can I make this SQL query <strong>update <code>zoneId</code> when a match is found, and keep the current value when no match is found?</strong></p>