Computer Science Essentials, Unit 5, Lesson 4 of 4

Writing SQL

GCSE Computer Science, Databases and SQL, 35 minutes

Sign in

Write your own SQL and run it: SELECT with WHERE, AND, OR, LIKE and ORDER BY, a query over two tables, and INSERT, UPDATE and DELETE, each checked against the tables.

What you will learn

  • Write a SELECT query with WHERE, AND, OR and LIKE
  • Sort results with ORDER BY
  • Write a query over two linked tables
  • Write INSERT, UPDATE and DELETE statements
  • Change data and then query it

How these questions are marked

In this lesson you write real SQL in the editor.

It runs on the tables in the question, and the tests check what it gives back.

  • A query test compares the records your last SELECT returns with the records it should return. Some tests also check the order.
  • After an INSERT, UPDATE or DELETE, a test looks at the table to see whether the right records changed and nothing else did.
  • Every test starts from a fresh copy of the tables, so you can run your SQL as often as you like.
  • Your mark is your share of the tests passed.

Field names and text must match the table exactly. 'drama' is not the same text as 'Drama'.

The rest of this lesson and its 19 practice questions are locked.

In this lesson

  1. How these questions are marked
  2. Writing a SELECT query
  3. Two tables
  4. Changing data
  5. Try it: Your first query

19 practice questions, marked as you go; about 35 minutes in all.

Key terms

Tests, More than, Fewer than, No more than, No less than

In this unit: Databases and SQL

Tables, records and fields, primary and foreign keys, why linked tables beat one big table, SQL queries over one or two tables, changing data with INSERT, UPDATE and DELETE, and reading and writing CSV files.

All of Databases and SQL