Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (19k points)
recategorized by

I have multiple set of data to insert at once, say 4 rows.

My table has three columns: Person, Id and Office.

INSERT INTO MyTable VALUES ("John", 123, "Lloyds Office");

INSERT INTO MyTable VALUES ("Jane", 124, "Lloyds Office");

INSERT INTO MyTable VALUES ("Billy", 125, "London Office");

INSERT INTO MyTable VALUES ("Miranda", 126, "Bristol Office");

Can I insert all 4 rows in a single SQL statement?

1 Answer

0 votes
by (119k points)

You can use the following SQL query to insert multiple rows just using a single INSERT statement:

INSERT INTO MyTable (Person, Id, Office) VALUES

( Value1, Value2, Value3 ), ( Value1, Value2, Value 3)

INSERT INTO MyTable (Person, Id, Office)

VALUES ('John', 123, 'Lloyds Office'),

               ('Jane', 124, 'Lloyds Office'),

               ('Billy', 125, 'London Office')

You can check out this SQL Tutorial to understand how to use the INSERT statement.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...