title: Delete rows older than 14 days in MySQL
body: <blockquote>
    <p><strong>Summary</strong></p>
  </blockquote>
  
  <p>I need to purge the history of a table from rows that are older than 14 days.</p>
  
  <p>Being no MySQL Expert, my searches lead me to this:</p>
  
  <pre><code>delete
      from SYS_VERROUS_POLICE
      where idModificationPolice not in (
                  select distinct idModificationPolice
                      from SYS_VERROUS_POLICE
                      where date(dateHeureModification) 
                              between curdate() and curdate() - interval 14 day
              );
  </code></pre>
  
  <blockquote>
    <p><strong>Thrown Exception</strong></p>
  </blockquote>
  
  <p>But then I'm stuck with this error message:</p>
  
  <p><strong><em>Error Code: 1093. You can't specify target table 'SYS_VERROUS_POLICE' for update in FROM clause.</em></strong></p>
  
  <p>What the...</p>
  
  <blockquote>
    <p><strong>Context</strong></p>
  </blockquote>
  
  <p>MySQL seems to be operating in safe mode, so I just won't be able to perform a DELETE where matching dates.</p>
  
  <p>In safe-mode, if I try to delete using only the date field, it doesn't comply.</p>
  
  <pre><code>delete  
    from SYS_VERROUS_POLICE     
   where date(dateHeureModification) &lt; curdate() - interval 14 day    
  
  Error Code: 1175. You are using safe update mode and you tried to update a table without a 
  WHERE that uses a KEY column
  To disable safe mode, toggle the option in Preferences -&gt; SQL Editor and reconnect. 
  0,00071 sec
  </code></pre>
  
  <p>Am I missing something?</p>