How to calculate the value of string in mysql -
i have store procedure in mysql, in query string @str = 5*2+1 want calculate string , return number. in sql server can exec ('select'+ @str)
, returns 11
thanks
you can use following, careful sql injection when using dynamic queries:
prepare stmt1 'select 5*2+1'; execute stmt1; deallocate prepare stmt1;
using code example, try (be careful sql injection!)
set @calc = concat('select ', '5*2+1', ' result'); prepare stmt1 @calc; execute stmt1; deallocate prepare stmt1;
Comments
Post a Comment