Mysql function call

前端 未结 4 875
伪装坚强ぢ
伪装坚强ぢ 2021-02-10 04:34

If I call a function several time then will it execute every time or just execute once and the value will be used then after several time? Example:

 select my_fu         


        
4条回答
  •  不思量自难忘°
    2021-02-10 05:08

    Why not use a variable that catch the value of your function. For example:

    declare var_function (datatype(size)); // just to declare proper data type for your function
    
    set var_function = my_function('filed');
    
    select var_function, var_function/field2, 
            (var_function*field1)/field3,
    
    ....from my_table    where group by filed1;
    

    in that case, you'll be going to reuse the function result and no need to repeat the process of the function.

提交回复
热议问题