Update time value for every second row
I am trying to update a time value in my MySQL table and am having trouble
working the logic out.
I want to make it so it reads:
ID Time
1 17:00
2 17:00
3 17:08
4 17:08
5 17:16
6 17:16
and so on.
I can select every second row by using MOD on the ID number but I am
having trouble specifying the correct update value for the row.
UPDATE `table`
set `Time` = DATE_ADD(Convert('17:00:00',TIME),INTERVAL (`ID`-2)*8 MINUTE)
where `ID` mod 2 = 1
If you require any clarifications please let me know and thanks in advance.
No comments:
Post a Comment