title: Move rows from TableA into Table-Archive
body: <p>Is it possible to move rows that are 3 days old into an other table called "Table_Archive" automatically in mysql ones a week?</p>
  
  <p>tableA ex:</p>
  
  <pre><code>ID | stringvalue | Timestamp
  1  | abc         | 2011-10-01
  2  | abc2        | 2011-10-02
  3  | abc3        | 2011-10-05
  4  | abc4        | 2011-10-10
  5  | abc5        | 2011-10-11
  </code></pre>
  
  <p><strong>After the move</strong></p>
  
  <p>tableA:</p>
  
  <pre><code>ID | stringvalue | Timestamp
  4  | abc4        | 2011-10-10
  5  | abc5        | 2011-10-11
  </code></pre>
  
  <p>Table_Archive:</p>
  
  <pre><code>ID | stringvalue | Timestamp
  1  | abc         | 2011-10-01
  2  | abc2        | 2011-10-02
  3  | abc3        | 2011-10-05
  </code></pre>
  
  <p>And when new input comes into tableA it wont be any problems with ID (PK) in the next move?</p>
  
  <p>What Ive got:</p>
  
  <pre><code>CREATE PROCEDURE clean_tables ()
  BEGIN
      BEGIN TRANSACTION;
  
      DECLARE _now DATETIME;
      SET _now := NOW();
  
      INSERT
      INTO    Table_Archive
      SELECT  *
      FROM    TableA
      WHERE   timestamp &lt; _now - 3;
      FOR UPDATE;
  
      DELETE
      FROM    TableA
      WHERE   timestamp &lt; _now - 3;
  
      COMMIT;
  END
  </code></pre>
  
  <p>How do I change _now to be the date 3 days ago?</p>