0
0
SQLquery~5 mins

INSERT INTO multiple rows in SQL

Choose your learning style9 modes available
Introduction
We use INSERT INTO multiple rows to add many new records to a table in one simple step. This saves time and keeps the data organized.
When adding several new customers to a customer list at once.
When entering multiple new products into an inventory database.
When recording several new orders in a sales system at the same time.
When importing a batch of new employee records into a staff table.
Syntax
SQL
INSERT INTO table_name (column1, column2, column3) VALUES
  (value1a, value2a, value3a),
  (value1b, value2b, value3b),
  (value1c, value2c, value3c);
Each set of values inside parentheses represents one new row to add.
Separate each row with a comma, and end the statement with a semicolon.
Examples
Adds three new students with their names and ages in one command.
SQL
INSERT INTO students (name, age) VALUES
  ('Alice', 20),
  ('Bob', 22),
  ('Charlie', 19);
Inserts two new products with their price and stock quantity.
SQL
INSERT INTO products (product_name, price, stock) VALUES
  ('Pen', 1.5, 100),
  ('Notebook', 3.0, 50);
Sample Program
This creates an employees table, adds three employees at once, then shows all employees.
SQL
CREATE TABLE employees (
  id INT PRIMARY KEY,
  name VARCHAR(50),
  department VARCHAR(50)
);

INSERT INTO employees (id, name, department) VALUES
  (1, 'John Doe', 'Sales'),
  (2, 'Jane Smith', 'Marketing'),
  (3, 'Emily Davis', 'HR');

SELECT * FROM employees;
OutputSuccess
Important Notes
Make sure the order of values matches the order of columns listed.
All rows must have the same number of values.
Use single quotes for text values.
Summary
INSERT INTO multiple rows lets you add many records in one command.
List columns once, then provide multiple sets of values separated by commas.
This method is faster and cleaner than inserting rows one by one.