O Level · Computer Science 0478

SQL

Revise SQL for Computer Science 0478 (O Level) — revision notes and instant AI marking.

📖 Revision notes · preview
  Cambridge (CIE) IGCSE Computer Science

SQL — Structured Query Language

SQL is the language you use to ask a database questions — "give me these rows," "only if they match this condition," "sorted this way," "add these numbers up." Once you can read a table and translate "what I want" into SELECT / FROM / WHERE, you can write almost any query this course throws at you.

  Summary — What This Chapter Covers

  • SQL is a programming language used to interact with a DBMS (Database Management System).
  • SQL lets you select, order, sum, and count data.
  • SELECT and FROM are the two commands that appear in almost every query — SELECT says what columns you want, FROM says which table.
  • WHERE filters rows based on a condition; AND / OR combine multiple conditions.
  • Wildcards (* and %) let you match "everything" or "partial text" like names starting with a letter.
  • ORDER BY sorts your results (ASC = ascending, DESC = descending).
  • SUM adds up a numeric column; COUNT counts how many rows match.

  What is SQL?

Think of a database table like a giant spreadsheet sitting inside a piece of software called a DBMS (Database Management System) — think MySQL, Oracle, or Microsoft Access working behind the scenes. You can't just "look" at the spreadsheet and pick out rows by eye when it has millions of entries. Instead, you write a short, precise instruction in SQL, and the DBMS does the searching for you and hands back exactly what you asked for.

SQL stands for Structured Query Language. The word "structured" matters — SQL queries always follow a predictable shape (SELECT ... FROM ... WHERE ...), a bit like a sentence template. Once you know the template, you're just filling in the blanks with your own table and column names.

Analogy
Imagine a librarian with a card catalogue of a million books. Instead of walking every aisle yourself, you tell the librarian: "Find me books, written after 1990, by authors starting with 'K', sorted by title." That instruction — precise, structured, filtered, sorted — is exactly what an SQL query does to a database table.

SQL allows a user to do four main things with data:

  • Select data — pull out specific rows/columns
  • Order data — sort the results
  • Sum data — add up a numeric column
  • Count data — count how many rows match

  SELECT and FROM — The Core Pair

Every SQL query that retrieves data starts with these two commands working together. SELECT tells the DBMS which columns you want back. FROM tells it which table to look in. You genuinely cannot write one without the other for a basic query — SELECT on its own doesn't know where to look, and FROM on its own doesn't know what to return.

General Pattern SELECT column1, column2, ... FROM tableName;

If you want every column in the table, you don't have to type each one out — you use the wildcard * to mean "all columns."

SELECT * FROM users;
-- retrieves ALL columns from the 'users' table

SELECT name, age
FROM users;
-- retrieves only the 'name' and 'age' columns
Remember
Practice Question 1

Name Country Customers

Practice Question 2

tbl_people

🔓 Read the full SQL note → You're seeing the preview · sign in to read it all
Also in the full note
  • WHERE, AND & OR — Filtering Data
  • Wildcards — * and %
  • ORDER BY — Sorting Results
  • SUM and COUNT — Aggregate Functions
  • Full Worked Example (Exam-Style)
  • What to Memorise
  • Concepts Checklist
  • Exam Tips & Common Mistakes
What's inside
📖 Revision notes 🎯 Learn mode ✦ AI flashcards ✓ Instant AI marking 🧊 3D explorers 🧪 Experiments & simulations 📈 Progress tracking
📄 Practise SQL with Computer Science 0478 past papers Every paper with its mark scheme — answer online, marked instantly. Open →

Read the full SQL notes free

That's the preview — create a free account to read the rest, plus flashcards and practice questions with instant AI marking. No credit card.

Unlock the full notes free →

More Computer Science topics