
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 to insert an array of values in a MySQL table with a single INSERT?
Let us first create a table −
mysql> create table DemoTable ( ClientId int, ClientName varchar(50) ); Query OK, 0 rows affected (0.62 sec)
Insert some records in the table using insert command. Here, we are inserting multiple values using only a single INSERT −
mysql> insert into DemoTable values(101,'Adam'),(102,'Chris'),(103,'Robert'),(104,'Sam'),(105,'Mike'); Query OK, 5 rows affected (0.16 sec) Records: 5 Duplicates: 0 Warnings: 0
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----------+------------+ | ClientId | ClientName | +----------+------------+ | 101 | Adam | | 102 | Chris | | 103 | Robert | | 104 | Sam | | 105 | Mike | +----------+------------+ 5 rows in set (0.00 sec)
- Related Questions & Answers
- Insert multiple values in a temporary table with a single MySQL query?
- Insert multiple sets of values in a single statement with MySQL?
- How to insert only a single column into a MySQL table with Java?
- Fastest way to insert with multiple values in a single MySQL query?
- Insert all the values in a table with a single MySQL query separating records by comma
- How to insert multiple rows in a table using a single INSERT command in program?
- How do I insert multiple values in a column with a single MySQL query?
- Select and insert values with preceding zeros in a MySQL table
- Auto insert values into a MySQL table in a range?
- Insert record in a MySQL table with Java
- Insert values in two tables with a single stored procedure call in MySQL
- Insert values in a table by MySQL SELECT from another table in MySQL?
- Insert JSON into a MySQL table?
- How can I create a stored procedure to insert values in a MySQL table?
- How to insert multiple rows with single MySQL query?
Advertisements