The hard part is evaluating the expression after you've put values where variable names were. For that, you have a number of options:

1. Find a third-party numerical expression evaluation program to which you can pass a string that is the expression to evaluate; write your program to run that program, giving it the expression with its variables replace.

2. Use SQL to do that evaluation. The statement

`SELECT 1+2*3 AS [Result]`

(that is valid Microsoft T-Sql; for MySql there may be minor differences) will evaluate your answer for you. But, you'll have to ensure that none of your expressions use operators or functions that SQL can't understand, or that are SQL aggregation operators.3. Hard, especially since you're new to programming: translate your database-stored expressions into .Net expression trees. Essentially, this is dynamically creating a .net program from a text string.

4.You could also look into Reflection (look for Emit) which can be used to generate .Net classes which you can then compile and link to. Probably far more work than you need, but it's always there as an option.

5. Simpler than Nos. 3 and 4, if you have a well-defined set of operators - implement your own calculation engine. You'll have to dynamically parse the expressions (or, save cached pre-parsed expressions when they get added to the database) and build a graph of objects that your engine can traverse, calculating a result as it goes.

None of these options is without pitfalls. If your expressions are strings typed by a user they are almost guaranteed to have random errors - unbalanced parentheses, strange characters that don't belong in a mathematical expression, etc. Whichever approach you take, you'll have to handle the errors that arise from such expressions.

If you're in a hurry, No. 1 is probably your best option.

If you can't find a solution to No. 1, No. 2 is the next easiest (actually, maybe easier than No. 1).

No. 3 is the most technically challenging. If you have the time and inclination it will be very rewarding.

No. 4 I really don't recommend. It'll generate a lot of executable code (DLLs) lying around, there'll be a lot to learn, and there's a risk that you'll fall into the error of "when the only tool you have is a hammer, everything is a nail."

No. 5 would be fun, easier than No. 3, and will teach you some valuable things about data structures and algorithms (and, will help you understand what's going on if you try No. 3).

Have fun!

This is not "equation", this is a numerical expression...

You can either do a calculation in SQL (but why?) or write a query to get all the numbers using, say, the names of columns/tables and calculate the expression in C#. What could be unclear?

—SA

otherwhise you have to create a huge logical interpreter to identyfy the calculations which have to be done.

Usually, we store values in database and write programs in the form of methods/functions to perform calculations. We retrieve values from database using SQL and pass them to the appropriate methods/functions to process and get the results.