0
0
MySQLquery~20 mins

INSERT INTO multiple rows in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Multi-Row Insert Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the result of inserting multiple rows?
Given the table students with columns id (auto-increment), name, and age, what will be the content of the table after running this query?

INSERT INTO students (name, age) VALUES ('Alice', 21), ('Bob', 22), ('Charlie', 23);
MySQL
SELECT * FROM students ORDER BY id;
A[{"id":1,"name":"Alice","age":21}]
B[{"id":1,"name":"Alice","age":21},{"id":2,"name":"Bob","age":22},{"id":3,"name":"Charlie","age":23}]
CSyntaxError
D[]
Attempts:
2 left
💡 Hint
Remember that INSERT INTO with multiple VALUES adds all rows in one query.
📝 Syntax
intermediate
2:00remaining
Which INSERT syntax is correct for multiple rows?
Which of the following queries correctly inserts multiple rows into a table products with columns product_name and price?
AINSERT INTO products (product_name, price) VALUE ('Pen', 1.5), ('Pencil', 1.0);
BINSERT INTO products (product_name, price) VALUES ('Pen', 1.5); ('Pencil', 1.0);
CINSERT INTO products VALUES ('Pen', 1.5), ('Pencil', 1.0);
DINSERT INTO products (product_name, price) VALUES ('Pen', 1.5), ('Pencil', 1.0);
Attempts:
2 left
💡 Hint
Check the keyword for multiple rows and punctuation.
optimization
advanced
2:00remaining
Why prefer INSERT INTO multiple rows over multiple single-row inserts?
You want to add 1000 new users to a table. Which approach is more efficient and why?
AUse one INSERT INTO with 1000 rows in VALUES to reduce overhead.
BUse 1000 separate INSERT INTO statements, one per row, for clarity.
CUse DELETE then INSERT for all rows to refresh the table.
DUse UPDATE statements to add new rows one by one.
Attempts:
2 left
💡 Hint
Think about how many times the database has to process queries.
🔧 Debug
advanced
2:00remaining
Identify the error in this multi-row INSERT query
What error will this query cause?

INSERT INTO orders (order_id, product) VALUES (101, 'Book'), (102, 'Pen', 5);
ASyntaxError due to mismatched number of columns and values in second row
BNo error, inserts two rows correctly
CRuntime error: duplicate primary key
DTypeError: wrong data type for product
Attempts:
2 left
💡 Hint
Check if each row has the same number of values as columns specified.
🧠 Conceptual
expert
2:00remaining
What happens if you omit column names in multi-row INSERT?
Given a table employees with columns id (auto-increment), name, and department, what will happen if you run:

INSERT INTO employees VALUES (NULL, 'John', 'Sales'), (NULL, 'Jane', 'HR');
AOnly first row inserted, second causes error
BError because column names are missing
CRows inserted with auto-increment ids assigned automatically
DRows inserted but id remains NULL causing duplicates
Attempts:
2 left
💡 Hint
If you omit columns, values must match all columns in order.