How do I insert multiple values in a column with a single MySQL query?


To insert multiple values in a column, the syntax is as follows −

insert into yourTableName values(yourValue1),(yourValue2),..........N;

To understand the above syntax, let us create a table −

mysql> create table DemoTable2022
   -> (
   -> Department varchar(100)
   -> );
Query OK, 0 rows affected (0.49 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable2022 values('Computer Science'),('Information Technology'),
   ('Civil'),('Mechanical'),('Electronics'),('Electrical');
Query OK, 6 rows affected (0.46 sec)
Records: 6 Duplicates: 0 Warnings: 0

Display all records from the table using select statement −

mysql> select *from DemoTable2022;

This will produce the following output −

+---------------------------+
| Department                |
+---------------------------+
| Computer Science          |
| Information Technology    |
| Civil                     |
| Mechanical                |
| Electronics               |
| Electrical                |
+---------------------------+
6 rows in set (0.00 sec)

Updated on: 06-Apr-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements