Home›Study Resources›Computer Science›
What is SQL?
Computer Science
National 5

What is SQL?

SQL (Structured Query Language) is the language used to create, search and edit data in a relational database. At National 5, you use SELECT, FROM, WHERE and ORDER BY to search, and INSERT, UPDATE and DELETE to change data. Example: Write a query to show the name of every pupil in the Pupil table with a mark over 70, highest first. SELECT name, mark FROM Pupil WHERE mark > 70 ORDER BY mark DESC; Answer: This query lists pupils scoring over 70, from highest to lowest.

SQL is the standard language for working with relational databases. In SQA National 5 Computing Science (Database design and development), you implement queries with SELECT, FROM, WHERE and ORDER BY, and edit data with INSERT, UPDATE and DELETE. WHERE conditions can use AND, OR and comparison operators.

Worked example

Write an SQL query to display the name and mark of pupils in the Pupil table with a mark greater than 70, sorted from highest to lowest mark.

  1. Choose the fields to show: SELECT name, mark.
  2. Name the table: FROM Pupil.
  3. Add the condition: WHERE mark > 70.
  4. Sort the results: ORDER BY mark DESC.

Answer: SELECT name, mark FROM Pupil WHERE mark > 70 ORDER BY mark DESC;

Reviewed by

Want one-to-one support?

One-to-one online tuition can help you build confidence in your subject. Find a tutor who teaches your course.

Find a Tutor

Learn face to face in Glasgow

Prefer in-person lessons? Visit the ExpertTutor Glasgow Southside centre.

See the centre