Back

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

I have a 1-many number of records that need to be entered into a table. What is the best way to do this in a query? Should I just make a loop and insert one record per iteration? Or is there a better way?

1 Answer

0 votes
by (40.7k points)

If you are using the MySQL manual, then use this code:

To include multiple lists of column values, each enclosed within parentheses and separated by commas. Use INSERT statements that use VALUES syntax which can insert multiple rows like this: 

INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);

Related questions

0 votes
1 answer
asked Nov 26, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Dec 18, 2020 in SQL by Appu (6.1k points)

Browse Categories

...