Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6916791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:38:54+00:00 2026-05-27T09:38:54+00:00

I have a very large database (with new information being added everyday) that a

  • 0

I have a very large database (with new information being added everyday) that a little cakePHP app was built for searching the database online. Because it is too big and slow,I want to stage the data in a new database with:

- only the last 12 months 
- converts the serial varchar field data into INT (for sorting and "in btw" searches)
- Only take numeric serials less than 5 numbers (< 99999)

OLD DATABASE

 id(key)           serial (varchar)   Date(datetime)                                           
 --------          -----------    --------------  
 1                 12345              2011-02-15 23:50:26   
 2                 12345678           2008-12-15 23:50:26
 3                 abc45              2009-12-15 23:50:26

NEW DATABASE

 id(key)           serial (INT)   Date(datetime)                   
 --------          -----------    --------------  
 1                 12345          2011-02-15 23:50:26

.
I need a MYSQL script that i can schedule to run everyday and append new entries (with the above conditions) to the new database and use this database for the cakePHP app

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:38:55+00:00Added an answer on May 27, 2026 at 9:38 am

    You could execute a daily script, after first running an initial import:

    First script, imports 12 months of data:

    INSERT INTO new_database.table_name (serial, date)
    SELECT old.serial, old.date
    FROM old_database.table_name old
    WHERE old.date > DATE_SUB(CURDATE(), INTERVAL 1 YEAR)
    AND LENGTH(old.serial) < 6;
    

    Daily script, just imports the previous 24 hours:

    INSERT INTO new_database.table_name (serial, date)
    SELECT old.serial, old.date
    FROM old_database.table_name old
    WHERE old.date > DATE_SUB(CURDATE(), INTERVAL 24 HOUR)
    AND LENGTH(old.serial) < 6;
    

    I interpreted your serial number length criteria as 5 characters or less (< 6) as your example has 5 digits.

    In case the daily script doesn’t run exactly on time, to avoid skips or duplicates you may want to edit the scripts somewhat. For example, if the serial numbers are unique you can avoid inserting duplicate records by selecting only serials that are not already present in the new database table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large database of normalized order data that is becoming very slow
I have a very large Oracle database, with many many tables and millions of
I have a very large code base that contains extensive unit tests (using CppUnit).
I have a very large file that looks like this (see below). I have
I have a very large codebase (read: thousands of modules) that has code shared
I have a very large app, 1.5 million lines of C++, which is currently
I have a very large table in my database and I am starting to
I have a series of queries against a very mega large database, and I
I have a sequence of sql queries that result in very large datasets that
I have a very large database in Mysql. I need it to be maintained

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.