aimnova.
DashboardMy LearningPaper MasteryStudy Plan

Aimnova site navigation

Stay in the loop

Get the latest study resources and updates

New features, study tips and exam insights — straight to your inbox.

IB Diploma

  • IB Past Papers
  • IB Study Notes
  • IB Question Bank
  • IB Mock Exams
  • IB Revision

IB Subjects

  • IB Math AA
  • IB Math AI
  • IB Economics
  • IB Business Management
  • IB Physics
  • IB Biology
  • View all IB subjects→

IB Past Papers

  • IB Math AA HL Past Papers
  • IB Math AA SL Past Papers
  • IB Math AI HL Past Papers
  • IB Math AI SL Past Papers
  • IB Economics HL Past Papers
  • IB Economics SL Past Papers
  • IB ESS Past Papers
  • View all past papers→

Study Resources

  • Study Notes
  • Question Bank
  • Mock Exams
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aimnova.

AI-powered study platform for smarter revision, past-paper analysis and examiner-style feedback.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.8afc4e3

Aimnova is not affiliated with or endorsed by the International Baccalaureate Organization (IB).

NotesComputer ScienceTopic 3.3Joining two tables
Back to Computer Science Topics
3.3.24 min read

Joining two tables

IB Computer Science • Unit 3

Your first topic is free to keep

Know exactly what to write for full marks

Practice with exam questions and get AI feedback that shows you the perfect answer — what examiners want to see.

Start Free

Contents

  • Asking a question of two tables
  • The clauses, in the order they run
  • Filtering, matching and grouping
  • Exam-style question
The big idea: Normalising split the data across tables, so most real questions need two of them at once.

JOIN pairs each row of one table with the matching rows of the other, using the foreign key that links them.

Two tables joined, filtered, narrowed and sorted — one clause at a time. Step through it.

Interactive diagram

Explore the labelled diagram, charts and maps for this topic in full study mode.

Claim your free topic

Free preview

This is the free notes preview

You're reading the free notes. Aimnova Pro unlocks the full study experience — and you can try it with your first topic free to keep:

  • FlashcardsLock in vocabulary and key terms with spaced repetition.
  • Practice questionsAnswer exam-style questions and get instant AI marking.
  • Mock exams & past-paper vaultSit full mocks and see exactly how examiners award marks.
  • Personalised study planA daily plan built around your exam date and weak areas.
Start Studying Free Full access to Aimnova Pro · cancel anytime
Written in one order, applied in another: SELECT is written first but applied near the end.

The database works out which rows first — FROM, JOIN, WHERE — and only then decides which columns to hand back.

Which rows

  • FROM — the first table
  • JOIN … ON — pair it with the second, on the matching key
  • WHERE — keep only rows meeting a condition
  • Conditions combine with AND, OR and NOT

Which columns

  • SELECT — name the columns wanted
  • DISTINCT — remove duplicate rows from the result
  • Prefix a column with its table when both tables have it

How it comes back

  • ORDER BY — sort the result
  • ASC ascending (the default), DESC descending
  • Without it, the order is not guaranteed at all
The ON condition is the whole join: It names the two columns that must match — almost always a foreign key and the primary key it points at.

Leave it out and the database pairs every row with every row, which on two 1,000-row tables gives a million.

Memorize terms 3x faster

Smart flashcards show you cards right before you forget them. Perfect for definitions and key concepts.

Try Flashcards FreeYour first topic is free to keep • No credit card required
1

Comparing and ranges

2

Pattern matching with LIKE

3

Grouping with GROUP BY

4

HAVING, not WHERE

Reading that query: Join the two tables · keep only students whose name starts with A · group what is left by club · keep only clubs with more than two such students · sort by count, largest first.

How this is tested — you must write valid SQL with the clauses in the right order and the join condition correct. It comes up two ways:

Paper 1 Section A

  • Construct a query across two tables, 4-6 marks
  • Add filtering, pattern matching or ordering
  • Say what a given query returns

Paper 1 Section B — case study

  • Query the case study's tables
  • Explain what a query would tell that organisation
The classic trap: Using WHERE where HAVING is needed. A condition on a count or total can only be applied after GROUP BY — and only HAVING runs there.
IB-style questionConstruct[5 marks]

Using Student (StudentID, Name, YearGroup) and Membership (StudentID, Club), write a query listing the names of Year 12 students in clubs beginning with D, sorted by name.

Model answer plan

See the mark-by-mark plan — for / against / judgement, with marking guidance — in study mode.

Claim your free topic

Try an IB Exam Question — Free AI Feedback

Test yourself on Joining two tables. Write your answer and get instant AI feedback — just like a real IB examiner.

which columns a join between Student and Class would normally match on. [1 mark]

Related Computer Science Topics

Continue learning with these related topics from the same unit:

3.1.1Relational databases
3.2.1Database schemas
3.2.2ERDs
3.2.3Data types
View all Computer Science topics

Improve your exam technique

Command terms, paper structure, and mark-scheme tips for Computer Science

Previous
3.3.1SQL language types
Next
Updating data with SQL3.3.3

21 exam-style questions ready for you

Students who practice on Aimnova improve their scores by 15% on average. Get instant feedback that shows exactly how to improve your answers.

Practice Now — FreeView All Computer Science Topics