Question
In the context of this exercise, is there a shorter way to insert multiple rows in a table?
Answer
Yes, instead of inserting each row in a separate INSERT
statement, you can actually insert multiple rows in a single statement.
To do this, you can list the values for each row separated by commas, following the VALUES
clause of the statement.
Here is how it would look,
INSERT INTO table (col1, col2, col3)
VALUES
(row1_val1, row1_val2, row1_val3),
(row2_val1, row2_val2, row2_val3),
(row3_val1, row3_val2, row3_val3);