
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
MySQL query to insert multiple records quickly
To insert multiple records quickly, use a single INSERT and follow the below syntax −
insert into yourTableName values(yourValue1,yourValue2,...N),(yourValue1,yourValue2,...N).....N;
To understand the above syntax, let us create a table −
mysql> create table DemoTable2007 ( Amount1 int, Amount2 int, Amount3 int ); Query OK, 0 rows affected (1.36 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable2007 values(450,600,700),(1000,200,3000), (800,900,1200),(1300,1500,2000),(40000,50000,6700); Query OK, 5 rows affected (0.11 sec) Records: 5 Duplicates: 0 Warnings: 0
Display all records from the table using select statement −
mysql> select * from DemoTable2007;
This will produce the following output −
+---------+---------+---------+ | Amount1 | Amount2 | Amount3 | +---------+---------+---------+ | 450 | 600 | 700 | | 1000 | 200 | 3000 | | 800 | 900 | 1200 | | 1300 | 1500 | 2000 | | 40000 | 50000 | 6700 | +---------+---------+---------+ 5 rows in set (0.00 sec)
- Related Articles
- Insert records from multiple tables in MySQL
- How to insert multiple rows with single MySQL query?
- Delete selective multiple records using MySQL DELETE query
- MySQL update multiple records in a single query?
- Insert multiple rows in a single MySQL query
- How to multiple insert or batch insert at a time in MySQL query?
- MySQL query to return multiple row records with AND & OR operator
- Fastest way to insert with multiple values in a single MySQL query?
- MongoDB query to insert but limit the total records
- Use UNION ALL to insert records in two tables with a single query in MYSQL
- Insert multiple values in a temporary table with a single MySQL query?
- Is there any easy way to add multiple records in a single MySQL query?
- MySQL query to display records from a table filtered using LIKE with multiple words?
- MySQL Query to set currency records
- MySQL query to select top 10 records?

Advertisements