- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we insert values into a table with the help of MySQL self-computed output?
152 Lectures 16 hours
87 Lectures 5.5 hours
We can insert the values into a table with the help of the self-computed output returned by MySQL. In this case, we do not need to use dummy ‘dual’ table. The syntax can be as follows −
INSERT INTO table_name(column1,column2,column3,…) Select value1,value2,value3,…;
In the example below, we have inserted the values in ‘testing’ table by using the MySQL self-computed output.
mysql> Create table testing(id int, item_name varchar(10)); Query OK, 0 rows affected (0.15 sec) mysql> Insert into testing (id,item_name)Select 1,'Book'; Query OK, 1 row affected (0.11 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> Insert into testing (id,item_name)Select 2,'Pen'; Query OK, 1 row affected (0.11 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> select * from testing; +------+-----------+ | id | item_name | +------+-----------+ | 1 | Book | | 2 | Pen | +------+-----------+ 2 rows in set (0.00 sec)
- How can we use MySQL self-computed output from any expression, function etc. for inserting values in a row?
- How can we insert data into a MySQL table?
- How can we subtract values in MySQL table with the help of LEFT JOIN?
- How can we insert a new row into a MySQL table?
- How can we add values into the columns of a MySQL table?
- What is the way to get self-computed output from MySQL without a dummy table named dual?
- How can we use INSERT() function to insert a new string into the value of a column of MySQL table?
- Can we insert records in a MySQL table without auto_increment values?
- MySQL INSERT INTO SELECT into a table with AUTO_INCREMENT
- How can we use WHERE clause with MySQL INSERT INTO command?
- Auto insert values into a MySQL table in a range?
- How can we display all the records from MySQL table with the help of PHP script?
- How can we filter data with the help of MySQL subquery?
- Insert JSON into a MySQL table?
- How can we insert data into an existing MySQL table by using PHP script?