levo

Exchanging Data

SQL: Interpreting and Modifying Queries

  • 3 things to know
  • Component 01

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.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

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

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

If it matches, the search .
succeedsfailsrestarts

Blank Blitz makes facts automatic

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

A0 + 0 gives 0.
B0 + 1 gives 1.
C1 + 1 gives 0 carry 1.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

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

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

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.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

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