Mysql Multiplication Columns

Mysql Multiplication Columns is used to provide the column that is the outcome product of all the records in the respective columns of a table.

Mysql Multiplication Columns

Mysql Multiplication Columns

     

Mysql Multiplication Columns is used to provide the column that is the outcome product of all the records in the respective columns of a table.

Understand with Example

The Tutorial describe you an example from 'Mysql Multiplication Columns'.To understand the example we simply create a table 'Multiplication' with required fieldname and datatype respectively.

 

 

 

Query for creating table name Multiplication:

mysql>  CREATE TABLE Multiplication(
    ->              a int(10),
    ->              b int(19),
    ->              c int(21)
    ->             );
Query OK, 0 rows affected (0.03 sec)

Query for Multiple insertion of data in table:

The Query for inserting a records or rows to the table 'Multiplication' is given below :

mysql> insert into Multiplication (a,b,c)values
    ->                     (12,13,15),
    ->                     (22,23,25),
    ->                     (32,33,35),
    ->                     (42,43,45),
    ->                     (52,53,55),
    ->                     (62,65,64
Query OK, 6 rows affected (0.00 sec)
Records: 6  Duplicates: 0  Warnings: 0

Query to view data inserted in table:

The Query given below is used to return the records from table 'multiplication'.

mysql> select * from multiplication;

Output:

mysql> select * from multiplication;
+------+------+------+
| a    | b    | c    |
+------+------+------+
| 12   | 13   | 15   |
| 22   | 23   | 25   |
| 32   | 33   | 35   |
| 42   | 43   | 45   |
| 52   | 53   | 55   |
| 62   | 65   | 64   |
+------+------+------+
6 rows in set (0.00 sec)

Query to view Mysql multiplication of data inserted in table:

The below Query return you the result set in column 'Multiplication' as outcome product of records in the respective columns 

mysql> select a,b,c,a*b*c as Multiplication from multiplication;

Output:-

+------+------+------+----------------+
| a    | b    | c    | Multiplication |
+------+------+------+----------------+
| 12   | 13   | 15   | 2340           |
| 22   | 23   | 25   | 12650          |
| 32   | 33   | 35   | 36960          |
| 42   | 43   | 45   | 81270          |
| 52   | 53   | 55   | 151580         |
| 62   | 65   | 64   | 257920         |
+------+------+------+----------------+
6 rows in set (0.00 sec)