Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

MySQL insert into Statement Exercises: Insert 3 rows by a single insert statement

MySQL insert into Statement: Exercise-5 with Solution

5. Write a SQL statement to insert 3 rows by a single insert statement.

Sample Solution:

INSERT INTO countries VALUES('C0001','India',1001),
('C0002','USA',1007),('C0003','UK',1003);

Let execute the above code in MySQL 5.6 command prompt.

Here is the structure of the table:

mysql> SELECT * FROM COUNTRIES;
+------------+--------------+-----------+
| COUNTRY_ID | COUNTRY_NAME | REGION_ID |
+------------+--------------+-----------+
| C0001      | India        |      1001 |
| C0002      | USA          |      1007 |
| C0003      | UK           |      1003 |
+------------+--------------+-----------+
3 rows in set (0.00 sec)

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous:Write a SQL statement to insert NULL values against region_id column for a row of countries table.
Next:Write a SQL statement insert rows from country_new table to countries table.

What is the difficulty level of this exercise?