How are data queried, inserted and updated using SQL and query by example?
Using a database through Structured Query Language (SELECT, INSERT, UPDATE, DELETE) and query by example, including selecting, sorting and joining data.
A CCEA A-Level Digital Technology answer on using a database with Structured Query Language: SELECT, INSERT, UPDATE and DELETE, filtering, sorting and joining tables, and the query by example alternative.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
CCEA wants you to use a database through Structured Query Language (SELECT, INSERT, UPDATE, DELETE) and through query by example, including selecting, filtering, sorting and joining data. This is the practical side of databases: getting data in, out and changed.
Selecting data with SQL
A basic query names the columns, the table, an optional filter and an optional sort:
SELECT Surname, Town
FROM Students
WHERE Year = 13
ORDER BY Surname;
This returns the surname and town of Year 13 students, sorted alphabetically. Using SELECT * returns all columns, which is convenient but wasteful when only some are needed.
Inserting, updating and deleting
INSERT INTO Students (StudentID, Surname, Year, Town)
VALUES (1024, 'Kelly', 13, 'Bangor');
UPDATE Students
SET Town = 'Newtownards'
WHERE StudentID = 1024;
DELETE FROM Students
WHERE StudentID = 1024;
Joining tables
Because data is split across normalised tables, queries often need a JOIN to combine them on a matching key:
SELECT Students.Surname, Bookings.BookingDate
FROM Students
JOIN Bookings ON Students.StudentID = Bookings.StudentID
WHERE Bookings.BookingDate = '2026-06-16';
This links each booking to the student who made it by matching the foreign key in Bookings to the primary key in Students. A JOIN is needed precisely because normalisation splits related data across tables; without it, a query could only see one table at a time.
Summarising data
SQL can also summarise rather than just list. Aggregate functions such as COUNT, SUM, AVG, MAX and MIN calculate a single value over many rows, and GROUP BY produces one result per group:
SELECT Town, COUNT(*) AS NumberOfStudents
FROM Students
GROUP BY Town;
This counts how many students live in each town, returning one row per town. Aggregate queries turn raw records into the kind of summary information a manager actually wants, which is why they are examined alongside the basic SELECT.
Query by example
Query by example (QBE) is a visual alternative to SQL. The user is shown a grid of the fields and enters criteria under the columns they want (for example "13" under Year and a sort order under Surname); the database then builds and runs the underlying query. QBE is easier for non-technical users because no syntax must be memorised, while SQL is more precise, more powerful for complex queries, and can be saved and embedded in programs.
Try this
Q1. Write an SQL statement to return all columns of the Books table where Genre is 'Science'. [2 marks]
- Cue.
SELECT * FROM Books WHERE Genre = 'Science';
Q2. State which SQL keyword sorts the results of a query. [1 mark]
- Cue. ORDER BY.
Q3. Explain why a DELETE statement should normally include a WHERE clause. [2 marks]
- Cue. The WHERE clause selects which records to remove; without it, DELETE removes every record in the table, causing unintended data loss.
Exam-style practice questions
Practice questions written in the style of CCEA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
CCEA A2 14 marksA table Students has fields StudentID, Surname, Year and Town. Write an SQL query to list the surname and town of all students in Year 13, sorted by surname.Show worked answer →
Use SELECT with a WHERE filter and an ORDER BY clause.
SELECT Surname, Town
FROM Students
WHERE Year = 13
ORDER BY Surname;
The SELECT clause names the columns to return, FROM names the table, WHERE filters to Year 13 only, and ORDER BY sorts the results by surname (ascending by default).
Markers award marks for the correct SELECT of the two named fields, the correct WHERE condition, and the ORDER BY clause. Selecting all fields with an asterisk when only two are asked for, or omitting the WHERE filter, loses marks. Quoting the number 13 as text is also penalised because Year is numeric.
CCEA A2 15 marksExplain the difference between SQL and query by example (QBE), and state one advantage of each.Show worked answer →
Contrast how the user expresses the query, then give an advantage of each.
SQL (Structured Query Language) is a text-based language: the user types commands such as SELECT, INSERT, UPDATE and DELETE to manipulate data. Query by example (QBE) is a visual approach: the user fills in a grid, entering criteria under the relevant fields, and the system builds the query for them.
Advantage of SQL: it is precise and powerful, can express complex queries and joins, and can be saved and reused in programs. Advantage of QBE: it is easier for non-technical users because no syntax must be memorised; the user picks fields and types criteria into a form.
Markers reward the text-versus-visual contrast and a valid advantage of each. Saying QBE is "just SQL with pictures" without the no-syntax benefit, or claiming SQL is always easier, limits the marks.
Related dot points
- The features of a relational database (tables, primary and foreign keys, relationships), entity relationship modelling, and normalisation to third normal form.
A CCEA A-Level Digital Technology answer on relational databases: tables, primary and foreign keys and relationships, entity relationship modelling, and normalisation to third normal form to remove redundancy.
- Optimising databases with indexing, maintaining data integrity, and securing databases with access rights, encryption and backup, including concurrency in multi-user systems.
A CCEA A-Level Digital Technology answer on optimising databases with indexing, maintaining data integrity, and securing databases with access rights, encryption, backup and concurrency control in multi-user systems.
- Data mining and the discovery of patterns in large data sets, the characteristics of big data, and the uses, benefits and ethical concerns of analysing large data sets.
A CCEA A-Level Digital Technology answer on data mining (discovering patterns in large data sets), the characteristics of big data, and the uses, benefits and ethical concerns of analysing large data sets.
- Network protocols and the role of TCP/IP, transmission media (wired and wireless), and error detection and correction techniques such as parity, checksum and the check digit.
A CCEA A-Level Digital Technology answer on network protocols and TCP/IP, wired and wireless transmission media, and error detection and correction techniques including parity, checksums and check digits.
- Network types (LAN, WAN, PAN), network topologies (bus, star, ring and mesh) and the hardware that connects a network.
A CCEA A-Level Digital Technology answer on computer networks: the types of network (LAN, WAN and PAN), the network topologies (bus, star, ring and mesh) with their advantages and disadvantages, and the hardware that connects a network.
Sources & how we know this
- CCEA GCE Digital Technology specification — CCEA (2016)