AQA · GCSE · Computer Science

    Course version: 8525 · Version from Sept 2020

    Be able to use SQL to retrieve data from a relational database, using the…

    Full specification wording

    Structured query language (SQL): Be able to use SQL to retrieve data from a relational database, using the commands:

    SQL is the language used to query a relational database.

    Checked against the AQA 8525 specification (opens in a new tab) on .

    • Point 1 of 10

    Study notes

    From the checked teaching notes for this specification point.

    The idea

    SQL is the language used to query a relational database. To retrieve data you write a SELECT statement naming the columns you want, then FROM the table that holds them. A WHERE clause filters rows by a condition, for example WHERE YearGroup = 10, using the equality operator to match a value. Comparison operators such as > and < test ranges, and AND or OR combine conditions. Text values go in single quotation marks; numbers do not. The result is a set of rows containing only the requested columns that satisfy the condition. Practise reading a small table, predicting which rows a given statement returns, and spotting errors such as a missing FROM or a misspelt column name.

    What earns the marks

    • SELECT names the columns to return; FROM names the table they come from.
    • WHERE filters rows using a condition, for example WHERE YearGroup = 10, with the equality operator between column and value.
    • Comparison operators such as >, < and <> test values; AND and OR combine two or more conditions.
    • Text values are enclosed in single quotation marks, while numeric values are written without quotes.
    • The output contains only the selected columns and only the rows that satisfy the WHERE condition.

    Common mistakes and how to put them right

    • Writing the equality test with a word instead of the symbol.

      Put it right: Place the equals sign between the column name and the value, as in WHERE Score = 50.

    • Omitting the FROM clause.

      Put it right: To state the table after FROM so the database knows where to look.

    • Putting numbers in quotation marks or leaving text unquoted.

      Put it right: Quote text values only and write numeric values bare.

    Exam tips

    • Trace a statement clause by clause: SELECT, then FROM, then WHERE, checking each column name against the table.
    • When asked what a query returns, list the columns and the qualifying rows rather than describing the statement in general terms.
    • Check quotation marks and operators carefully, because a single wrong symbol changes which rows are returned.

    Try the lesson

    The start of the Structured query language (SQL): Be able to use SQL to retrieve data from a relational database, using the commands: lesson, made from checked teaching notes for this specification point.

    Have a go first

    A table called Students stores pupil records. Which SQL command is used to retrieve rows from this table?

    There is more to this lesson

    The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.

    Carry on with the full lesson

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge

    Test your understanding of Structured query language (SQL): Be able to use SQL to retrieve data from a relational database, using the commands:

    Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.

    Take topic quiz

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge