CodeBlanks Logo Icon CodeBlanks

Multiple rows

Insert many rows in a single INSERT.

Multi-row insert

A single INSERT can add many rows. You separate value sets with commas.

INSERT INTO products (id, name, price)
VALUES (4, 'Çanta', 25), (5, 'Cetvel', 3);

This query adds two rows in one query.

The values given with VALUES are inserted into products as new rows.

Multi-row insert — details

Multi-row insert is faster than one-by-one. Each value set goes in parentheses, separated by commas; no comma after the last set.

Practice Multi-row insert

Insert id=4 'Bag' and id=5 'Ruler' into products in one query.

Starter code

query.sql
-- insert two rows
INSERT INTO products (id, name)
VALUES

Sample solution

query.sql
INSERT INTO products (id, name)
VALUES (4, 'Çanta'), (5, 'Cetvel')

Expected output

2 satır eklendi

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Multiple rows: match the terms

Term Meaning
INSERT insert
VALUES values
comma separate sets
INTO into

2 Two rows

Question
INSERT INTO products (id, name) VALUES (1, 'A'), ____;
Answer
INSERT INTO products (id, name) VALUES (1, 'A'), (2, 'B');

Explanation: (2, 'B') is the right answer.

3 What separates value sets in multi-row insert?

  • A space
  • A colon
  • A semicolon
  • A comma Correct answer

Explanation: Value sets are separated by commas.

All lessons in Beginner