Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL 4.1 Script Update Table Help needed. 2

Status
Not open for further replies.

Cranger

Programmer
Apr 4, 2001
54
0
0
US
Hi All.

OK, like most threads on here, I am a newbie.

We have a MySQL 4.1 Database running on a RedHat Linux box. Every so often (nightly?), I want to run a job against the tables to select the records from "X" Days ago and update a flag in that table. First, can this be accomplished? And second, can anyone point me in the right direction?

Thanks.
 
I notice that you haven't as yet marked any of the answers given to you as valuable. If you're not getting the right answers, read faq222-2244 to see why - if they are the right answers, please mark them so others using the forum will recognise useful answers.

For this question, the MySQL manual is a good starting point. Look up the UPDATE query which gives a detailed example. If you have a further problem, show us what you've tried, and what result you get so we can be of more specific help.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
thanks johnwm,

I understand about writing an update query, but I am not sure how I can regularly run it. Do I have to write a stored procedure and envoke it via shell script? Can I run the query on a schedule?
 
Thanks for your response. The 'regularly run' bit will probably be covered in the Linux desktop forum forum619

Sorry I can't help directly, but I don't do Linux (yet)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
You can certainly have it run as a cron job. That involves adding an entry to /etc/crontab, with a command something like:[tt]
mysql -u username -ppassword dbname -e 'update tbl set flag=1 where dt=curdate()-interval 5 day'
[/tt]
The "man crontab" command will explain the file's syntax.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top