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

screenshot of command mysql workbench

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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -