
- 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
Insert multiple rows in a single MySQL query
Let us first create a table −
mysql> create table DemoTable1384 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20), -> StudentAge int -> ); Query OK, 0 rows affected (0.63 sec)
Insert some records in the table using insert command. Here, we are inserting multiple rows in a single query −
mysql> insert into DemoTable1384(StudentName,StudentAge) values('Chris Brown',21),('David Miller',22), -> ('Carol Taylor',19),('Adam Smith',23); Query OK, 4 rows affected (0.11 sec) Records: 4 Duplicates: 0 Warnings: 0
Display all records from the table using select statement −
mysql> select * from DemoTable1384;
This will produce the following output −
+-----------+--------------+------------+ | StudentId | StudentName | StudentAge | +-----------+--------------+------------+ | 1 | Chris Brown | 21 | | 2 | David Miller | 22 | | 3 | Carol Taylor | 19 | | 4 | Adam Smith | 23 | +-----------+--------------+------------+ 4 rows in set (0.00 sec)
- Related Articles
- How to insert multiple rows with single MySQL query?
- How to get multiple rows in a single MySQL query?
- How to obtain multiple rows in a single MySQL query?
- Insert multiple values in a temporary table with a single MySQL query?
- Fastest way to insert with multiple values in a single MySQL query?
- Update multiple rows in a single MongoDB query?
- How do I insert multiple values in a column with a single MySQL query?
- How to insert multiple rows in a table using a single INSERT command in program?
- Multiple COUNT() for multiple conditions in a single MySQL query?
- Update multiple rows in a single column in MySQL?
- Implement multiple COUNT() in a single MySQL query
- Change multiple columns in a single MySQL query?
- MySQL update multiple records in a single query?
- MySQL query to sort multiple columns together in a single query
- Implement multiple LIKE operators in a single MySQL query

Advertisements