FutureLogic Lesson → Databases → Cambridge IGCSE 0478

SQL SELECT, WHERE and ORDER BY Explained for Students

Basic SQL becomes simple once you know the job of each keyword. This lesson gives you one clear mental model for reading a query: which fields, which table, which records, in what order.

SQL SELECT, WHERE and ORDER BY Explained for Computer Science Students

Basic SQL is easier than it looks, once each keyword has a job in your head. Students get stuck when they try to read a query like a sentence, left to right, without knowing what each part is for.

So let us give every keyword a plain-English question. Read a query by answering these four questions in turn:

SELECT = what fields?  •  FROM = which table?  •  WHERE = which records?  •  ORDER BY = in what order?
⏱ Estimated time: 13–16 minutes
🎯 Level: Cambridge IGCSE 0478
📚 Pairs with the Topic 9 revision notes

By the end of this lesson, you will be able to:

Explain what SELECT and FROM do.
Use WHERE to filter records.
Use ORDER BY with ASC and DESC.
Read a combined query in stages.
Tell fields and records apart.
Avoid the common SQL mistakes.

Our example table

Every query below runs against this Students table.

StudentIDNameAgeScore
101Alice1581
102Ben1665
103Chen1590
104Dia1672

SELECT and FROM

SELECT Name, Score FROM Students;

In plain English: “Display the Name and Score fields from the Students table.” SELECT chooses the fields (columns) and FROM names the table. This query returns all four students, but only their Name and Score.

Selecting every field

If you want every field rather than a named list, use an asterisk in place of the field names:

SELECT * FROM Students;

The * means “all fields”, so this returns every column for every student — StudentID, Name, Age and Score. Reach for it when you genuinely need the whole record; name the fields you want when you do not, because a shorter result is easier to read and to mark.

WHERE: filtering records

SELECT Name, Score FROM Students WHERE Age = 15;

WHERE filters records (rows), not fields. It keeps only the rows that satisfy the condition. Here, only students aged 15 remain:

NameScore
Alice81
Chen90

Notice the split of responsibilities: SELECT decided the columns, WHERE decided the rows. Keeping those two jobs separate in your mind prevents most SQL errors.

ORDER BY: sorting results

SELECT Name, Score FROM Students ORDER BY Score DESC;

ORDER BY sorts the results. ASC means ascending and DESC means descending. Ascending is normally the default when no direction is given, consistent with the FutureLogic Topic 9 material. Sorted by Score descending, the students run 90, 81, 72, 65 — Chen, Alice, Dia, Ben.


Putting it together

SELECT Name, Score FROM Students WHERE Age = 15 ORDER BY Score DESC;

Read a combined query in stages rather than all at once:

  1. Table = Students.
  2. Keep records where Age = 15.
  3. Display the Name and Score fields.
  4. Sort by Score, descending.

That leaves Chen (90) then Alice (81). Four keywords, four questions answered in order — and the result is obvious.

Exam Tip: read by role, not left to right

Do not try to read SQL like an English sentence from left to right. Read it by the role of each keyword:

Fields → Table → Filter → Sort.

Answering “what fields, which table, which records, in what order” will get you through almost every basic query question.

Common Mistakes:
  • Writing field names after FROM (fields belong after SELECT).
  • Confusing records with fields.
  • Using WHERE to choose columns — WHERE chooses rows.
  • Reversing ASC and DESC.
  • Assuming ORDER BY filters records — it only sorts them.
  • Forgetting quotes where string values require them.

Where this leads next

Once this structure is secure, the aggregate functions become much easier. Functions such as SUM() and COUNT() simply act on the records your query has already selected — so if you can pick the right rows and fields, you are most of the way to summarising them too.

Ascending is the default

If you leave the direction off, the sort is ascending by default. These two queries do exactly the same thing:

ORDER BY Score ASC; ORDER BY Score;

Both list the scores from lowest to highest: 65, 72, 81, 90 — Ben, Dia, Alice, Chen. Write ASC in when you want to be explicit, but know that a bare ORDER BY already means ascending.

A note on quotes

Numbers are written plainly, but text values usually need quotation marks. To find a student by name you would write:

SELECT Name, Score FROM Students WHERE Name = 'Chen';

The quotes tell the database that Chen is a piece of text to match, not the name of a field. Forgetting them around a string is one of the most common reasons a simple query fails, so it is worth building the habit now.

Check Your Understanding

  1. Which keyword chooses the fields to display?
  2. Does WHERE filter fields or records?
  3. What does ORDER BY Score DESC do?
Check the answers

1. SELECT chooses the fields. 2. WHERE filters records (rows). 3. It sorts the results by the Score field in descending order, highest first.

Final Summary

SELECT

Chooses the fields (columns) to display.

FROM

Names the table to read from.

WHERE

Filters the records (rows) by a condition.

ORDER BY

Sorts results; ASC ascending, DESC descending.

Fields, table, filter, sort. Answer those four questions and any basic SQL query reads itself.
FutureLogic Education

Computer Science should feel clear, visual and achievable.

Download free revision PDFs, explore the Learning Hub, or try FutureLogic resources designed to help students move from confusion to confidence.