Jump to content

move table due in 10 days time


I-AM-OBODO

Recommended Posts

Don't do that - have multiple tables for the same thing. The big clue that it's a bad idea is that you have to run some automated thing to manage your database.

 

Any particular reason you want them in another table? Is there a problem with just querying the table directly?

SELECT * FROM orders WHERE DATEDIFF( duedate, CURRENT_DATE()) <= 10

That is enough to show only orders that are equal or less to 10 days before the column duedate.

 

Like requinix said: Do not move them to another table. That is bad practise.

 

ps. i assumed that you have a duedate column with the type DATE or DATETIME.

Hopefully you have realized that good database organization is how you properly manage any and all data.  By having it well designed you are then able to write queries to answer any question at any time without having to do things like you proposed in your post.  No need to move data to another table, no need to remove data when it 'expires'.  You simply store your data and query it and format the output to answer any question that is asked.  Yes - you eventually may remove data that is beyond use, but I suggest that you develop a process to archive the old data so that you can analyze it over long periods of time if that is the nature of your activity/business.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.