MYSQL Setting a limit on the min/max return value of a math function? -


i have been searching, find answers on how find, not set maximum return value of function.

what looking simple.. if want update entries in column in proportion themselves.. say.. set thecolumvalue=(thecolumnvalue+(thecolumnvalue*0.5));

is there no mysql function limit resulting value?

set thecolumvalue=functionname(thecolumnvalue+(thecolumnvalue*0.5), maximumvalue);

i have written own function handle need now, seems me such simple, , obvious need part of language. not finding in ref. manual or such function not exist in mysql?

of course there is. called least():

set thecolumvalue = least(thecolumnvalue+(thecolumnvalue*0.5), maximumvalue) 

more succinctly written as:

set thecolumvalue = least(thecolumnvalue * 1.5, maximumvalue) 

Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -