Insert multiple data using SET clause in MySQL?

MySQLMySQLi Database

Let us first create a table −

mysql> create table DemoTable1544
   -> (
   -> Id int ,
   -> Name varchar(20)
   -> );
Query OK, 0 rows affected (2.47 sec)

Insert some records in the table using insert command. We have inserted multiple data using SET clause −

mysql> insert into DemoTable1544 set Id=101,Name='John Doe';
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable1544 set Id=102,Name='Adam Smith';
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable1544 set Id=103,Name='Chris Brown';
Query OK, 1 row affected (0.12 sec)

Display all records from the table using select statement −

mysql> select * from DemoTable1544;

This will produce the following output −

+------+-------------+
| Id   | Name        |
+------+-------------+
|  101 | John Doe    |
|  102 | Adam Smith  |
|  103 | Chris Brown |
+------+-------------+
3 rows in set (0.00 sec)
raja
Published on 12-Dec-2019 06:06:14
Advertisements