Let us first create a table −
mysql> create table DemoTable -> ( -> NumberOfItems int, -> Amount int -> ); Query OK, 0 rows affected (0.57 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(4,902); Query OK, 1 row affected (0.45 sec) mysql> insert into DemoTable values(5,1000); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(3,80); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+---------------+--------+ | NumberOfItems | Amount | +---------------+--------+ | 4 | 902 | | 5 | 1000 | | 3 | 80 | +---------------+--------+ 3 rows in set (0.00 sec)
Following is the query for database manipulation −
mysql> select NumberOfItems,Amount,(NumberOfItems*Amount) AS PayableAmount from DemoTable;
Output
+---------------+--------+---------------+ | NumberOfItems | Amount | PayableAmount | +---------------+--------+---------------+ | 4 | 902 | 3608 | | 5 | 1000 | 5000 | | 3 | 80 | 240 | +---------------+--------+---------------+ 3 rows in set (0.00 sec)