AQA GCSE Computer Science · 3.7

Structured
Query Language

The four SQL commands you need, with real exam questions from AQA GCSE past papers
SELECT INSERT INTO UPDATE DELETE
Overview

The 4 SQL Commands

What the spec requires

AQA GCSE requires you to write four SQL commands. All of them appear in Paper 2. Here's what each one does:

  • SELECT Retrieve data from one or two tables — the most common question type, worth up to 6 marks
  • INSERT INTO Add a new record to a table
  • UPDATE Change the value of a field in existing records
  • DELETE Remove records from a table
💡 How marks are split in the exam The 6-mark two-table SELECT is the hardest SQL question on the paper — and where most marks are lost. INSERT, UPDATE and DELETE questions are shorter (usually 2–3 marks) but students perform worse on them because they practise SELECT most. Make sure you know all four.
📋 Rules that apply to every SQL command Quotes are required around text and date values: 'Leader', '2020-11-30'
Numbers do not get quotes: 5, 11
Use = not == in conditions — double equals is rejected by AQA mark schemes
SELECT

SELECT — Single Table

The 4 clauses

SELECT retrieves data from a table. There are four clauses — always written in this order, one per line:

Template
SELECT Field1, Field2, Field3 FROM TableName WHERE FieldName = 'value' ORDER BY FieldName ASC -- or DESC
Example
SELECT MemberID, FirstName, LastName FROM Member WHERE LastName = 'Ahmed' ORDER BY FirstName ASC
1
SELECT — list the exact fields asked for in the question. Never write SELECT * in an exam answer — the question will always name the specific fields needed.
2
FROM — the table the data is coming from.
3
WHERE — the filter condition. Chain multiple conditions with AND. Text and date values need single quotes: 'Leader', '2020-11-30'
4
ORDER BYASC = smallest/earliest first. DESC = largest/latest first. AQA ignores missing ASC but always include ORDER BY when the question asks for ordering — it's a mark.
SELECT

SELECT — Two Tables

The linking condition

When data comes from two tables, list both in FROM — and you must include a linking condition in WHERE to join them on their shared key field.

Template
SELECT Field1, Field2 FROM Table1, Table2 WHERE Table1.SharedKey = Table2.SharedKey AND OtherField = 'value' ORDER BY FieldName ASC
Example
SELECT FirstName, LastName, AwardName FROM Member, Award WHERE Member.MemberID = Award.MemberID AND AwardName = 'Leader' ORDER BY LastName ASC
⚠️ The most common mark-losing error in GCSE SQL Missing the linking condition. If you have two tables in FROM, you always need a WHERE line joining them on their shared key: Table1.KeyField = Table2.KeyField

Without it the query is wrong. This single mistake drops a mark every time.
💡 When to write Table.Field If both tables share the same field name (e.g. both have MemberID), write Member.MemberID to make it unambiguous. If the field name is unique to one table, you can write just the field name on its own — either way is accepted.
SELECT · Past Paper Question

SELECT — Two Tables

June 2022 · Q18.5
Database Schema
Member(MemberID, FirstName, LastName, DateOfBirth) Award(AwardID, MemberID, AwardName, DatePresented)
Question
AQA GCSE Computer Science · June 2022 · Paper 2 · Question 18.5
The youth club needs to produce a report listing the members who have been given the Leader award. The report must include both names of each member and the date the award was presented.

Write an SQL query that could be used to find this information. The results must be in order of the date the awards were presented, starting with the earliest.
[6 marks]
AO2 — right tables & conditions AO3 — correct SQL syntax
SELECT · Answer

SELECT — Answer

June 2022 · Q18.5
Model Answer
SELECT FirstName, LastName, DatePresented FROM Member, Award WHERE Member.MemberID = Award.MemberID AND AwardName = 'Leader' ORDER BY DatePresented ASC

How the 6 marks are awarded

1
Exactly three correct fields in SELECT: FirstName, LastName, DatePresented — no extras
2
First correct table in FROM: Member
3
Second correct table in FROM: Award
4
The linking condition: Member.MemberID = Award.MemberID
5
Filter condition: AwardName = 'Leader' — note the single quotes
6
Correct ORDER BY: ORDER BY DatePresented ASC
⚠️ Where marks are most commonly dropped ❌ Missing the linking condition entirely — straight to AND AwardName =

❌ Forgetting quotes: AwardName = Leader — rejected

❌ Using == instead of = — rejected

❌ Forgetting ORDER BY altogether

Maximum 5 marks if the query contains any errors.
INSERT

INSERT INTO — Syntax

Adding a new record

INSERT INTO adds a new record to a table. You name the table, list the fields in brackets, then provide the matching values.

Template
INSERT INTO TableName (Field1, Field2, Field3) VALUES (numericValue, 'text', 'date')
Example
INSERT INTO Member (MemberID, FirstName, LastName, DateOfBirth) VALUES (5, 'Alina', 'Ahmed', '2020-11-30')
1
The field list and values list must be in the same order. The first value maps to the first field, and so on.
2
Text values and dates get single quotes: 'Alina', '2020-11-30'. Numeric values do not: 5.
3
The keyword is VALUES — written on the second line, not VALUE or SET.
⚠️ Watch out — exam questions often give you partial SQL A common question style shows INSERT INTO with parts replaced by labels (A, B etc.) and asks you to identify the missing SQL. Make sure you know exactly which keyword goes where — table name after INSERT INTO, then VALUES on the line below.
INSERT · Past Paper Question

INSERT INTO

June 2022 · Q18.6
Database Schema
Member(MemberID, FirstName, LastName, DateOfBirth)
Question
AQA GCSE Computer Science · June 2022 · Paper 2 · Question 18.6
A new member joins the youth club. The following SQL is run to add their details to the database. Some of the SQL has been replaced by labels.

INSERT INTO A B (5, 'Alina', 'Ahmed', '2020-11-30')

State the SQL that should have been written in place of labels A and B.
[2 marks] — 1 mark each
INSERT · Answer

INSERT INTO — Answer

June 2022 · Q18.6
Answer
-- A = Member -- B = VALUES

Why each answer is right

A
Member — the table name. It goes immediately after INSERT INTO. You can see from the schema that Member is the only table that holds FirstName, LastName etc.
B
VALUES — the keyword that introduces the list of values on the second line. This is the exact word required — not VALUE, not SET, not INTO.
⚠️ Common wrong answers For A: writing a field name like MemberID instead of the table name Member

For B: writing VALUE (no S) or SET — both rejected. The keyword is specifically VALUES.

Both marks are independent — you can get one without the other.
UPDATE

UPDATE — Syntax

Changing existing records

UPDATE changes the value of a field in existing records. It has three clauses — always in this order:

Template
UPDATE TableName SET FieldName = NewValue WHERE ConditionField = value
Example — replace a value
UPDATE Member SET LastName = 'Ahmed' WHERE MemberID = 5
1
UPDATE is followed by the table name — not a field name. A common mistake is writing the field you want to change here instead: UPDATE Member ✓ not UPDATE LastName
2
SET — assigns the new value to a field. You can also use an expression to modify the current value: SET Score = Score + 10 adds 10 to whatever is already stored, rather than replacing it with 10.
3
WHERE — always include this. Without a WHERE clause, every record in the table gets updated — not just the one you intended.
DELETE

DELETE — Syntax

Removing records

DELETE removes records from a table. It's the simplest command — just two clauses.

Template
DELETE FROM TableName WHERE FieldName = 'value'
Example
DELETE FROM Member WHERE MemberID = 5
1
The keywords are DELETE FROM — both words together, followed by a single table name. Only one table can appear here.
2
Text values in WHERE still need quotes: WHERE AwardName = 'Bronze'
3
Always include WHERE. Without it, every record in the table is deleted permanently. If you need to delete on two conditions, chain them with AND: WHERE Field1 = 'X' AND Field2 = 'Y'
⚠️ Only one table after DELETE FROM Students sometimes write two tables here out of habit from SELECT queries. DELETE FROM TableA, TableB is wrong — DELETE FROM takes a single table only.
DELETE · Past Paper Question

DELETE

June 2023 · Q14.5
Database Schema
Student(StudentID, FirstName, LastName, YearGroup) Loan(LoanID, StudentID, CopyID, DepositPaid)
Question
AQA GCSE Computer Science · June 2023 · Paper 2 · Question 14.5
A copy of a book with CopyID PB002 has been returned. The loan record belonging to the student with StudentID TUC004 needs to be removed from the database.

Write an SQL query to delete this record from the Loan table.
[2 marks] — 1 mark per clause
DELETE · Answer + Quick Reference

DELETE — Answer & Summary

June 2023 · Q14.5
Model Answer
DELETE FROM Loan WHERE CopyID = 'PB002' AND StudentID = 'TUC004'

SELECT (two tables)

SELECT Field1, Field2
FROM Table1, Table2
WHERE Table1.Key = Table2.Key
AND Field = 'value'
ORDER BY Field ASC

INSERT INTO

INSERT INTO TableName (F1, F2, F3)
VALUES (123, 'text', 'date')

UPDATE

UPDATE TableName
SET Field = NewValue
WHERE IDField = value

DELETE

DELETE FROM TableName
WHERE Field = 'value'
🔑 Three rules that cover most exam errors (1) Always include the linking condition in two-table SELECT  ·  (2) Quote marks around all text and date values in WHERE and VALUES  ·  (3) Use = not == in conditions