Update field with max and min value in mysql -
i update percentage field maximum value of 1
, minimum of 0
relative value (eg. "add 25% current value")
this doesn't work:
update table set field = max(0, min(1, field+0.25))
update:
if value eg 0.85
should update 1
update
i'm using now:
update table set field = greatest(0, least(1, field+0.25))
update your_table set field = case when field > 0.75 1 else field + 0.25 end
especially in mysql can do
update your_table set field = least(1, field + 0.25)
for values can negativ can use
update your_table set field = case when field + ? > 1.0 1 when field + ? < 0.0 0 else field + ? end
Comments
Post a Comment