MySQL query solution: Mysql calculates the values of multiple fields. The original database is as follows. All fields are of the int type.
+----+---------+---------+| id | column1 | column2 |+----+---------+---------+| 1 | 1 | 2 || 2 | 3 | 4 || 3 | 5 | 6 |+----+---------+---------+
The expected output result value is
column1 * column2+----+--------+| id | Result |+----+--------+| 1 | 2 || 2 | 12 || 3 | 30 |+----+--------+
The SQL statement used is
SELECT id, (column1 * column2) AS Result FROM table;
Note: Mysql supports all commonly used Arithmetic Operators +,-, *,/, %, DIV (Division),-(negative) the column1 * column2 expression cannot be written as 'column1 '* 'column2' or 'column1 * column2 '. Mysql uses multiple field values as text links or databases, this time, you want to output column1 * column2 in the string format, that is:
+----+--------+| id | Result |+----+--------+| 1 | 1 * 2 || 2 | 3 * 4 || 3 | 5 * 6 |+----+--------+
Use the following SQL statement
SELECT id, CONCAT(column1, ' * ', column2) AS Result FROM table;
Add later