How to update all selected rows?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

How to update all selected rows?

Post by MicroBoy »

Hello,

I have a script which is run every 5 minutes, it gets about 100 queries. Sometimes it needs more than 5 minutes so the other scripts start too and it gets some of the queries that were selected in the first cronjob. At every execute of the query I mark it as done but because sometimes script can not be finished in 5 minutes it will not have time to mark all as executed so the next cron job will get those queries as well. Is there anyway at the begin of SELECT to mark all selected as finished?
User avatar
tr0gd0rr
Forum Contributor
Posts: 305
Joined: Thu May 11, 2006 8:58 pm
Location: Utah, USA

Re: How to update all selected rows?

Post by tr0gd0rr »

Would it make sense to use a transaction? BEGIN TRANSACTION; SELECT ...; UPDATE ...; COMMIT;

Obviously you wouldn't want your transaction to last 5+ minutes, but a transaction may be useful for you.
Post Reply