Re: automation question: How do I copy the data from one table to another table with a time stamp every night?

2001-01-24 Thread Steve Ruby

Chuck Barnett wrote:
 
 How do I copy the data from one table to another table with a time stamp
 every night?
 
 example:  table A contains x,y,z.
 
 at midnight, I want to copy table A's contents to table B (B has same
 fields, just adds a date field) and reset x,y,z to zero.
 


what do you mean by "reset to zero"  If you want to copy the files
from A to B you can just do

insert into B select x,y,z,now() from A;
delete form a;

if your date field in B is a TIMESTAMP type you can avoid the now()
part and do

inesrt into B (x,y,z) select x,y,z from A;
delete from a;

See the manual about the insert statement for more info.

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: automation question: How do I copy the data from one table to another table with a time stamp every night?

2001-01-24 Thread Chuck Barnett

Thanks for replying.
I know the SQL commands, I want to know how to automate the whole sequence.

I've always written php pages that do the calls.  I want to write a script
to do it on the server as a cron job or something.

thanks
Chuck
- Original Message -
From: "Steve Ruby" [EMAIL PROTECTED]
To: "Chuck Barnett" [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, January 24, 2001 12:34 PM
Subject: Re: automation question: How do I copy the data from one table to
another table with a time stamp every night?


 Chuck Barnett wrote:
 
  How do I copy the data from one table to another table with a time stamp
  every night?
 
  example:  table A contains x,y,z.
 
  at midnight, I want to copy table A's contents to table B (B has same
  fields, just adds a date field) and reset x,y,z to zero.
 


 what do you mean by "reset to zero"  If you want to copy the files
 from A to B you can just do

 insert into B select x,y,z,now() from A;
 delete form a;

 if your date field in B is a TIMESTAMP type you can avoid the now()
 part and do

 inesrt into B (x,y,z) select x,y,z from A;
 delete from a;

 See the manual about the insert statement for more info.



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: automation question: How do I copy the data from one table to another table with a time stamp every night?

2001-01-24 Thread Steve Ruby

Chuck Barnett wrote:
 
 Thanks for replying.
 I know the SQL commands, I want to know how to automate the whole sequence.
 
 I've always written php pages that do the calls.  I want to write a script
 to do it on the server as a cron job or something.


Ahhh, pardon my confusion, since this the MySQL list I presumed you were
asking a mysql question. Your question is a cron/unix/php question not
a mysql question..  

there are many options one would be to wite a PHP script that does
exactly what you need it to do when you "hit" it 

then simply put a cron job in that looks like

lynx url to my php script

If you don't know cron you'll have to read the 
man crontab
to understand the format of the crontab file or cron on your system, if
you
are using redhat you can simply put an executeable script with the
above line in it in the
/etc/cron.X directory where X is the interval you want it to run,
daily for example.

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: automation question: How do I copy the data from one table to another table with a time stamp every night?

2001-01-24 Thread Cal Evans

if you've compiled php without apache support (separately from your normal
php with apache support) but with mySQL then you can write php scripts that
run from the command line.  I usually keep a second php.ini for command line
scripts because they can run long.  This all could be put in a CRON job.

'course you could do it in PERL as well.

Cal
http://www.calevans.com


-Original Message-
From: Chuck Barnett [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 24, 2001 12:22 PM
To: Steve Ruby
Cc: [EMAIL PROTECTED]
Subject: Re: automation question: How do I copy the data from one table
to another table with a time stamp every night?


Thanks for replying.
I know the SQL commands, I want to know how to automate the whole sequence.

I've always written php pages that do the calls.  I want to write a script
to do it on the server as a cron job or something.

thanks
Chuck
- Original Message -
From: "Steve Ruby" [EMAIL PROTECTED]
To: "Chuck Barnett" [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, January 24, 2001 12:34 PM
Subject: Re: automation question: How do I copy the data from one table to
another table with a time stamp every night?


 Chuck Barnett wrote:
 
  How do I copy the data from one table to another table with a time stamp
  every night?
 
  example:  table A contains x,y,z.
 
  at midnight, I want to copy table A's contents to table B (B has same
  fields, just adds a date field) and reset x,y,z to zero.
 


 what do you mean by "reset to zero"  If you want to copy the files
 from A to B you can just do

 insert into B select x,y,z,now() from A;
 delete form a;

 if your date field in B is a TIMESTAMP type you can avoid the now()
 part and do

 inesrt into B (x,y,z) select x,y,z from A;
 delete from a;

 See the manual about the insert statement for more info.



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php