Is it possible to execute a string in MySQL?

I think you’re looking for something like this: SET @queryString = ( SELECT CONCAT(‘INSERT INTO user_group (`group_id`,`user_id`) VALUES ‘, www.vals) as res FROM ( SELECT GROUP_CONCAT(qwe.asd SEPARATOR ‘,’) as vals FROM ( SELECT CONCAT(‘(59,’, user_id, ‘)’) as asd FROM access WHERE residency = 9 ) as qwe ) as www ); PREPARE stmt FROM @queryString; … Read more

Evaluate string with math operators [duplicate]

Someone else added this and then it got deleted. I thought it was pretty cool because no 3rd party libraries required. class Program { static void Main(string[] args) { Console.WriteLine(Evaluate(“(4+8)*2”)); Console.ReadKey(); } public static double Evaluate(string expression) { DataTable table = new DataTable(); table.Columns.Add(“expression”, typeof(string), expression); DataRow row = table.NewRow(); table.Rows.Add(row); return double.Parse((string)row[“expression”]); } }

Best and shortest way to evaluate mathematical expressions

Further to Thomas’s answer, it’s actually possible to access the (deprecated) JScript libraries directly from C#, which means you can use the equivalent of JScript’s eval function. using Microsoft.JScript; // needs a reference to Microsoft.JScript.dll using Microsoft.JScript.Vsa; // needs a reference to Microsoft.Vsa.dll // … string expr = “7 + (5 * 4)”; Console.WriteLine(JScriptEval(expr)); // … Read more