Introduction
You use INSERT INTO multiple rows to add many new records to a table in one go. This saves time and makes your work easier.
INSERT INTO table_name (column1, column2, column3) VALUES (value1a, value2a, value3a), (value1b, value2b, value3b), ...;
INSERT INTO students (name, age) VALUES ('Alice', 20), ('Bob', 22);
INSERT INTO products (product_name, price) VALUES ('Pen', 1.5), ('Notebook', 3.0), ('Eraser', 0.5);
CREATE TABLE employees (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50), department VARCHAR(50)); INSERT INTO employees (name, department) VALUES ('John Doe', 'Sales'), ('Jane Smith', 'Marketing'), ('Emily Davis', 'HR'); SELECT * FROM employees;
INSERT INTO statement with multiple rows do in MySQL?INSERT INTO statement is used to add new data into a table.students with columns id and name?VALUES followed by multiple sets of values in parentheses separated by commas.VALUES (1, 'Alice'), (2, 'Bob') with commas separating rows.products(id INT, name VARCHAR(20)), what will be the result of this query?INSERT INTO products (id, name) VALUES (1, 'Pen'), (2, 'Pencil');
SELECT * FROM products;
INSERT INTO employees (id, name) VALUES (1, 'John') (2, 'Jane');
(1, 'John') and (2, 'Jane').orders(order_id, product, quantity). You have this query:INSERT INTO orders (order_id, product, quantity) VALUES (101, 'Book', 2), (102, 'Pen', 5), (101, 'Notebook', 3);
order_id is a PRIMARY KEY, duplicate values like 101 cause insertion errors.order_id values for each row to avoid conflicts.Pass the test and this pattern moves unknown