- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Multiply values of two columns and display it a new column in MySQL?
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)
- Related Articles
- Query to divide the values of two columns and display the result in a new column using MySQL wildcard?
- Divide numbers from two columns and display result in a new column with MySQL
- Extract the middle part of column values in MySQL surrounded with hyphens and display in a new column?
- How to round MySQL column with float values and display the result in a new column?
- How to select and display a list of values in one column that are available in two different MySQL columns?
- Select distinct values from three columns and display in a single column with MySQL
- MySQL query to count occurrences of distinct values and display the result in a new column?
- Display the sum of positive and negative values from a column in separate columns with MySQL
- MySQL query to get the length of all columns and display the result in a single new column?
- Display custom text in a new column on the basis of null values in MySQL?
- Add a new column to table and fill it with the data of two other columns of the same table in MySQL?
- Set the NULL values to 0 and display the entire column in a new column with MySQL SELECT
- Add a new column and set values in it on the basis of conditions in MySQL?
- Compare for NULL value and display value 1 for these values in a new MySQL column?
- Select multiple columns and display in a single column in MySQL?

Advertisements