Spec & Goals 3 min
AQA Spec 3.7.2 — Inserting data with INSERT INTO … VALUES
By the end of this lesson you can:
- Use
INSERT INTO … VALUESto add a new record. - Match values to the correct fields, quoting text and dates.
- Spot and fix common
INSERTerrors.
Warm-Up 5 min
So far every query read data. SQL can also add data. A new student joins — how do we put their record into the table?
Quick starter
To add a row, what two things must you give the database — and in what order?
Reveal the idea
The fields and the matching values, in the same order: INSERT INTO Student (…fields…) VALUES (…values…);
Key Concept — adding a record 14 min
INSERT INTO tableName (field1, field2, field3) VALUES (value1, value2, value3);
- List the fields you are filling, then the values in the same order.
- Text and dates go in single quotes (
'Lina'); numbers do not (107). - The number of values must match the number of fields.
- The primary key value must be unique and not already used.
Before
| StudentID | Name | Form | Town | Mark |
|---|---|---|---|---|
| 105 | Mei Ling | 11C | Penang | 88 |
| 106 | Hafiz | 10B | Kuala Lumpur | 72 |
Insert a new student
INSERT INTO Student (StudentID, Name, Form, Town, Mark) VALUES (107, 'Lina', '10A', 'Melaka', 83);
After
| StudentID | Name | Form | Town | Mark |
|---|---|---|---|---|
| 105 | Mei Ling | 11C | Penang | 88 |
| 106 | Hafiz | 10B | Kuala Lumpur | 72 |
| 107 | Lina | 10A | Melaka | 83 |
Worked Example — write and debug 12 min
Part 1 — write it: add product 12, "Teh Tarik", RM 2.50, category "Drinks" to Product(ProductID, ItemName, Price, Category).
INSERT INTO Product (ProductID, ItemName, Price, Category) VALUES (12, 'Teh Tarik', 2.50, 'Drinks');
Part 2 — find the errors in this attempt:
INSERT INTO Product (ProductID, ItemName, Price) VALUES (13, Roti Canai, '1.20', 'Food');
- Three fields are listed but four values are given — counts don't match.
Roti Canaiis text but has no quotes.'1.20'is a number wrongly written in quotes.
Corrected:
INSERT INTO Product (ProductID, ItemName, Price, Category) VALUES (13, 'Roti Canai', 1.20, 'Food');
Try It Yourself 12 min
Goal: Write an INSERT to add student 108, "Arif", form "10B", town "Ipoh", mark 69.
Goal: Explain why VALUES (108, Arif, 10B, Ipoh, 69) would fail.
Hint: which values are text?
Goal: A new INSERT reuses StudentID 103. Explain why this should be rejected.
📝 Exam Practice 10 min
Write an SQL statement to add a new student to the Student table: ID 109, name Suresh, form 11C, town Penang, mark 76.
Mark scheme
INSERT INTO Student (StudentID, Name, Form, Town, Mark)(1).VALUES (109, 'Suresh', '11C', 'Penang', 76);— correct values in order (1).- Text values quoted, numbers unquoted (1).
Identify two errors in: INSERT INTO Student (StudentID, Name) VALUES ('110', Tan, '10A');
Mark scheme
- Two fields listed but three values given (1).
- '110' is a number but quoted / Tan is text but not quoted (any one) (1).
Explain why an INSERT using an existing primary-key value should be rejected.
Mark scheme
- The primary key must be unique; a duplicate would break that / records could not be told apart (1).
Recap & Key Terms 3 min
INSERT INTO table (fields) VALUES (values); adds a record. Values must match the fields in number and order; quote text and dates, not numbers; the primary key must be unique. AQA assesses SELECT/WHERE/ORDER BY and INSERT only.
- INSERT INTO
- The SQL command that adds a new record to a table.
- VALUES
- The list of data, in field order, for the new record.
- Quoting rule
- Text and dates go in single quotes; numbers do not.
Homework 1 min
Task (≤ 15 min): A library adds a new member: MemberID 220, name "Devi", town "Ipoh", joined '2026-06-05'. Write the INSERT, then list two rules your statement obeys.
Model answer
INSERT INTO Member (MemberID, Name, Town, JoinDate) VALUES (220, 'Devi', 'Ipoh', '2026-06-05');
Rules obeyed: text and the date are in single quotes, the number is not; the number of values matches the fields and is in the same order; MemberID 220 is unique.
Award marks for: correct INSERT structure (1); correct quoting (1); two valid rules stated (1).