Skip to content
VirtusAcademy

SQL: Retrieving Data

FoundationHigherAQA

Revise SQL: Retrieving Data for GCSE Computer Science with this free worksheet and full mark scheme — Foundation and Higher exam-style questions with worked answers for AQA GCSE Computer Science (8525). SQL retrieves data from a database using SELECT, FROM and WHERE.

Free downloads

These worksheets and mark schemes are original, written for Virtus Academy and checked against the current AQA specification. Every worksheet comes with a full mark scheme.

Topic overview

SQL is the language used to work with databases. Retrieving data uses the SELECT statement.

The basic form is SELECT followed by the fields wanted, then FROM followed by the table name. SELECT Name, Age FROM Students retrieves just those two columns from every record in the Students table.

An asterisk retrieves every field: SELECT * FROM Students. This is convenient but usually poor practice in real systems, because it fetches data that may not be needed, which is slower and returns more than intended. Naming the fields explicitly makes the query's purpose clear to anyone reading it and returns only what is actually required.

Revision notes

The SELECT statement

SELECT lists the fields wanted; FROM names the table.

SELECT Name, Age FROM Students returns the Name and Age columns for every record in Students. Field names are separated by commas.

Selecting all fields

SELECT * FROM Students returns every field.

Convenient for a quick look, but usually poor practice in a real system: it fetches data that may not be needed, which is slower and returns more than intended.

Writing readable queries

Naming fields explicitly makes the query's purpose obvious to anyone reading it.

SQL keywords are conventionally written in capitals — SELECT, FROM, WHERE — which distinguishes them from table and field names at a glance.

Key points

  • SQL is used to work with databases.
  • SELECT retrieves data.
  • SELECT lists the fields wanted.
  • FROM names the table.
  • An asterisk selects every field.
  • Keywords are conventionally written in capitals.

Worked examples

Example 1

Write an SQL query to retrieve the Name and Email fields from a table called Members. [2 marks]

Working

SELECT Name, Emaillist the required fields after SELECT
FROM Membersname the table after FROM

Example 2

State what SELECT * FROM Books returns. [1 mark]

Working

Every field of every record in the Books tablestate what the asterisk retrieves

Example 3

Explain why naming fields explicitly is better than using an asterisk. [2 marks]

Working

Only the data actually needed is retrieved, which is fastergive the performance reason
and the query's purpose is clear to anyone reading itgive the readability reason

Common mistakes

  • Forgetting the FROM clause.

    Every SELECT needs a table named.

  • Separating field names without commas.

    Commas are required between field names.

  • Using an asterisk when specific fields are asked for.

    Read the question — it usually names the fields wanted.

  • Writing keywords in lower case.

    Capitals are the convention and make queries readable.

Exam tips

  • Write SQL keywords in capitals.
  • Separate field names with commas.
  • Always include the FROM clause.
  • Name fields explicitly rather than using an asterisk.

Key terms

SQL
The language used to work with databases.
SELECT
The keyword retrieving data.
FROM
The keyword naming the table.
Query
An instruction retrieving or modifying data.

Written and reviewed against the current AQA specification. Spotted an error? Let us know.