levo

Exchanging Data

SQL: Interpreting and Modifying Queries

  • 3 things to know
  • Component 01
Start revising · £5/month

Overview

Recall questions on SQL SELECT, FROM and WHERE, the wildcard and LIKE, AND and OR, JOIN, nested SELECT, INSERT INTO, DELETE and DROP, and interpreting, writing and correcting queries.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Explain what LIKE does, and what the % wildcard matches.

Key term

Explain step by step what this query does: SELECT Title FROM Book WHERE AuthorID = (SELECT AuthorID FROM Author WHERE Surname = 'Pratchett').

Key term

Write a query returning the title and author of every book in a Book table whose title begins with 'The'.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is SQL used for?

    Model answer

    SQL, Structured Query Language, is the standard language for interrogating and manipulating data in a relational database. It is used to retrieve records matching stated conditions, to add new records, to remove records, and to change the structure of the database itself, without the user needing to know how the data is physically stored.

  2. 2

    What do the SELECT, FROM and WHERE parts of a query each specify?

    Model answer

    SELECT lists the fields to be returned. FROM names the table or tables the data comes from. WHERE gives the condition a record must satisfy to be included, so it filters which records are returned. SELECT chooses the columns; WHERE chooses the rows.

  3. 3

    Explain what this query returns: SELECT Surname, Form FROM Student WHERE YearGroup = 12

    Model answer

    It returns the surname and form of every student in the Student table whose YearGroup field holds the value 12. Only those two fields are shown, and students in any other year group are excluded.

  4. 4

    What does the * mean in SELECT * FROM Book WHERE Genre = 'Crime'?

    Model answer

    The asterisk is a wildcard standing for all fields, so the query returns every field of every record in the Book table whose Genre is Crime, rather than a named subset of columns.

  5. 5

    Explain what LIKE does, and what the % wildcard matches.

    Model answer

    LIKE compares a text field against a pattern rather than requiring an exact match, and % is a wildcard standing for any sequence of characters, including none at all. So Surname LIKE 'M%' matches any surname beginning with M, Surname LIKE '%son' matches any ending in son, and Title LIKE '%dragon%' matches any title with dragon anywhere in it.

  6. 6

    Write a query returning the title and author of every book in a Book table whose title begins with 'The'.

    Model answer

    SELECT Title, Author FROM Book WHERE Title LIKE 'The%'

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Processors: Structure, Performance and Types
Input, Output and Storage
Systems Software
Applications Generation

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

If it matches, the search .
succeedsfailsrestarts

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

A global variable means a variable reachable from anywhere in the program.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Exchanging Data, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.