Community resourceWorksheet

OCR H446 1.3.2 SQL selection and conditions

Part 8 of 13 · H446 1.3.2 · Databases

SQL enters H446 1.3.2 here, held to the structures inside the OCR Appendix 5d assumed range. Students read a SELECT query clause by clause, predict exactly which rows it returns, then write their own using Boolean operators and wildcard patterns.

Students will:

  • interpret SELECT, FROM and WHERE as separate parts of one query
  • predict the rows a supplied query returns from a given table and say why
  • combine two conditions with Boolean operators
  • use a wildcard pattern to match part of a text field
  • write queries for a new catalogue schema while staying inside the assumed SQL range

Inside: 7 explanation cells, 2 multiple-choice questions, 2 fill-in-the-blanks cells, 3 written answers and 1 Python task. 29 marks, about 25 to 40 minutes.

Series: H446 1.3.2 · Databases, part 8 of 13.

Shared by Coding PathwayVerified teacher

  • 15 cells
  • About 30 minutes
  • CC BY-SA 4.0
  • Shared 31 Aug 2026
  • Updated 3 Sept 2026

Preview

The whole resource, exactly as a class sees it. Answers and marking are held back.

SQL selection and conditions

Structured Query Language (SQL) is a standard language used to interrogate and modify relational databases. This worksheet reads and writes the OCR Appendix 5d selection structures.

By the end, you will be able to

  • interpret SELECT, FROM and WHERE;
  • combine criteria with AND and OR;
  • use LIKE with % and select all fields with *;
  • predict result sets and write queries from requirements.

Reactivate: a field is a column; a record is a row; AND requires both criteria and OR requires at least one.

Build the result deliberately

How a SELECT query builds a resultFROM Eventchoose source tableWHERE ...keep matching rowsSELECT titlereturn chosen fieldsSQL is written SELECT ... FROM ... WHERE ... even though this model explains the logical data flow.

Example:

SELECT title, price
FROM Event
WHERE category = 'Workshop' AND spaces > 0

SELECT names the returned fields. FROM names the table. WHERE filters records. SQL keywords are commonly capitalised for readability, but letter case and layout are not the concepts being assessed.

Worked wildcard examples

LIKE 'Web%' matches text beginning with Web because % stands for zero or more characters.

LIKE '%Studio%' matches text containing Studio.

SELECT * FROM Event returns every field. The asterisk after SELECT and the percent sign inside a LIKE pattern are both wildcards, but they do different jobs.

Worked example
import sqlite3
db = sqlite3.connect(':memory:')
cur = db.cursor()
cur.execute('CREATE TABLE Event(event_id TEXT, title TEXT, category TEXT, price REAL, spaces INTEGER)')
cur.executemany('INSERT INTO Event VALUES (?, ?, ?, ?, ?)', [
    ('E1', 'Code Lab', 'Workshop', 12.0, 8),
    ('E2', 'Jazz Night', 'Music', 18.0, 0),
    ('E3', 'Robotics Studio', 'Workshop', 22.0, 5),
    ('E4', 'Web Studio', 'Workshop', 15.0, 12),
    ('E5', 'City Voices', 'Music', 10.0, 4)
])
query = "SELECT title FROM Event WHERE category = 'Workshop' AND spaces > 0"
for row in cur.execute(query):
    print(row[0])
Multiple choice1 mark

Which query returns the titles of Music events costing less than 15?

  • ASELECT * FROM Event WHERE category = 'Music' OR price < 15
  • BSELECT category FROM Event WHERE title = 'Music' AND price > 15
  • CSELECT title FROM Music WHERE Event < 15
  • DSELECT title FROM Event WHERE category = 'Music' AND price < 15
Multiple choice1 mark

Which structure is inside the current OCR Appendix 5d assumed SQL range?

  • AAn UPDATE statement that students must recall without support
  • BA nested SELECT used inside a WHERE comparison
  • CA LEFT OUTER JOIN that students must recall without support
  • DAn ALTER TABLE statement that students must recall without support
Fill in the blanks4 marks
gap 1 title, price gap 2 Event gap 3 category = 'Workshop' gap 4 spaces > 0
  • SELECT
  • FROM
  • WHERE
  • AND
  • OR
  • LIKE

Guided checkpoint: translate requirements

Requirement: return title and spaces for events whose title begins with Web or whose price is below 11.

Plan: output fields → source table → first condition → connector → second condition.

Model:

SELECT title, spaces
FROM Event
WHERE title LIKE 'Web%' OR price < 11
Written answer4 marks

Using the supplied Event rows, predict the titles returned by SELECT title FROM Event WHERE category = 'Music' OR spaces = 0 and explain why each appears.

Evaluate OR for each record.

Students type their answer here.

Written answer5 marks

Write SQL to return every field for Workshops priced from 12 up to and including 18 with spaces available.

Use two comparisons with AND; BETWEEN is outside the assumed list.

Students type their answer here.

Independent transfer: library catalogue

BOOK(book_id, title, genre, publication_year, available).

Write within the OCR Appendix 5d range. You do not need ORDER BY, BETWEEN or functions.

Written answer10 marks

Write two queries: (1) return title and publication_year for available books whose genre is 'Science'; (2) return every field for titles containing 'Data' or published before 2018.

Use `LIKE '%Data%'` for contains.

Students type their answer here.

Closed-book checkpoint

Complete each sentence from memory. There is no answer bank and correctness is held for teacher review.

Fill in the blanks4 marks
The SQL operator completion 1 matches a text pattern. The wildcard completion 2 represents any sequence of characters inside that pattern. The wildcard completion 3 after SELECT requests every field. The operator completion 4 keeps a row when either condition is true.

Review your understanding

Before submitting, check that you can explain the main distinction in your own words, apply it in an unfamiliar context and justify each consequence rather than only naming a feature.