Page 1 of 1
update four records daily out of six records----mysql---php
Posted: Thu Jan 21, 2016 1:05 pm
by LuckyBoyEver
Re: update four records daily out of six records----mysql---
Posted: Thu Jan 21, 2016 5:18 pm
by Christopher
LuckyBoyEver wrote:I have a table containing 6 records i want to display first four records today and today date should be saved against those 4 records.On the next day remaining two records should be displayed and first two records as well and date should be saved and flag should b incremented as well. i hope you guys are getting my point
What you want to do seems strange. Is it just the first four records when "ORDER BY person_id DESC" ? I ask because a database does not really have a "first four records". You can SELECT records by many criteria and sort them ascending/descending by any field.
If that is that is really what you want to do, then maybe something like:
Code: Select all
UPDATE mytable SET duty_flag=duty_flag+1, last_dty_timestamp=NOW() ORDER BY person_id DESC LIMIT 4
It would be a better design to be able to SELECT the rows you want to update based on values in their fields.
Re: update four records daily out of six records----mysql---
Posted: Thu Jan 21, 2016 9:38 pm
by LuckyBoyEver
there are total 6 persons and 4 duties........everyday 4 person will b on duty......next day remaining 2 and previous 2 will perform duty....
the one today on duty will increment his flag and update date as well
Re: update four records daily out of six records----mysql---
Posted: Thu Jan 21, 2016 11:52 pm
by Christopher
Search for "mysql round robin select". It is a little complicated. It may be easier to generate a schedule for the 24 day cycles in a separate table.