Combine alternatives with OR
Use OR when a row may match either of two valid alternatives.
Exam scope and assessment notes
This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6, Topic 9. It covers single-table databases only and the specified SELECT, FROM, WHERE, ORDER BY, SUM, COUNT, AND and OR content. The official specimen also demonstrates NOT in a filter. Multi-table joins, GROUP BY, database implementation and the separate 2029–2031 syllabus are not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers and human subject-teacher review remain outstanding.
Before you begin
- Be able to read a small table and compare values. Each lesson introduces the database and SQL terms it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
A row meets both conditions joined by OR. Is it included?
What you will learn
- Distinguish OR from AND
- Trace whether at least one condition is true
- Recognise a broad filter that may include both alternatives
OR accepts either true condition
A OR B is true when at least one condition is true. It is also true when both are true.
Use OR when a report needs records for either of two types, such as Topic = "Robotics" OR Topic = "Coding".
Avoid accidentally broadening a filter
AND narrows results by requiring all conditions; OR broadens results by accepting alternatives. Read the requirement carefully before choosing.
The official specimen also shows NOT applied to a Boolean field in a WHERE condition. That is useful to read, but the syllabus's listed SQL operators explicitly name AND and OR.
Pause and explain
A report needs records for either Category A or Category B. Which connector fits?
Worked example
A query returns sessions where Topic is Art OR Topic is Music. Which topic values are accepted?
Show the worked solution
- Test whether Topic equals Art.
- Test whether Topic equals Music.
- A row matching either condition is included.
Answer Art and Music records are included; any other topic is excluded.
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
A record has Type = Comedy. Does it pass Type = Comedy OR Type = Drama?
Give me a hint
Only one of the alternatives needs to be true.
Compare my reasoning
- The Comedy comparison is true.
- The Drama comparison is false.
- OR accepts the row because one test is true.
Yes, it matches the first alternative.
Look for these in your work
- Comparisons evaluated
- OR result
Write a query to return Title for performances of either Jazz or Classical from PERFORMANCES.
Give me a hint
Use two equality conditions joined by OR.
Compare my reasoning
- Select Title.
- Use the PERFORMANCES table.
- List the two allowed Type values.
SELECT Title FROM PERFORMANCES WHERE Type = "Jazz" OR Type = "Classical";
Look for these in your work
- Projection
- Both alternatives
- OR used
A report should show unpaid bookings for course CS1 only. Explain why Paid = FALSE OR CourseCode = "CS1" returns too many rows and correct it.
Give me a hint
Both properties must hold for each result.
Compare my reasoning
- OR accepts any unpaid booking, even from another course.
- It also accepts any CS1 booking, even if paid.
- Join the conditions with AND.
Use WHERE Paid = FALSE AND CourseCode = "CS1" because both requirements are necessary.
Look for these in your work
- Over-inclusion explained
- Correct connector
Common mistakes
- Using OR when a row must meet both rules
- Assuming OR excludes a row that meets both
- Treating NOT as one of the SQL operators explicitly listed in the syllabus
What can you explain now?
When does A OR B evaluate to true?
Compare with the explanation
When at least one condition is true
OR accepts either alternative or both.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
How does OR change the set of matching records compared with AND?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.