Hey guys,
I have a table in my database with an enum column with 3 values:
('Offline', 'Online', 'Expired')
I want to be able to do an update that cycles the value of the this column to the next value in the list... and wrap back to the start.
i.e.
'Offline' will change to 'Online'
'Online' will change to 'Expired'
'Expired' will change to 'Offline'
I understand that there are many ways to work around this, but I don't want to have to enter the values or total number of values.
Are there any built in functions to support this??
Is there a function that returns the length of an enum set of values?? <-- with this a mod() operation could be used to achieve the desired result.
This is where I got to in pseudo code:
UPDATE enum_tbl SET enum_col = (enum_col % count_of_poss_values) + 1;
And if not I believe there really should be..