Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

MySQL move date from one table to another

843854Apr 5 2004 — edited Apr 5 2004
I was wondering if there is a MySQL command that will let me move a selected row of data from one table to another. both tables have the same columns and declaration type (one table is actually an archived table on old data)

example
I wasnt to move all data in Table1 where the date is greater than 30 days old to Table 2
-- so the result should be...import all rows to Table 2 where the date is greater than 30 days old..and delete all date from Table 1 that is greater than 30 days.

currently..I'm doing three process
1) get all row that is greater than 30 days   
    "SELECT * FROM Table1 WHERE TO_DAYS(NOW()) - TO_DAYS(dateField) > 30"
2) insert data into Table2
    while (res.hasNext())
          TableData data = ..... // .get row
          dataList.add(data);
          for (int i = 0; i < dataList.size(); i++){
                pstm.setString.....
                pstm.addBatch()
          }
          pstm.executeBatch();
3) delete data from Table1
    "DELETE FROM Table 1 WHERE  TO_DAYS(NOW()) - TO_DAYS(dateField) > 30"
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 3 2004
Added on Apr 5 2004
7 comments
321 views