| English | 释义 | 拼音 |
|---|---|---|
| SQL/ˌes kjuː ˈel/ | 结构化查询语言 | jié gòu huà chá xún yǔ yán |
| query/ˈkwɪərɪ/ | 查询 | chá xún |
| record/ˈrekɔːd/ | 记录 | jì lù |
| field/fiːld/ | 字段 | zì duàn |
| condition/kənˈdɪʃn/ | 条件 | tiáo jiàn |
Asking a database questions
- SQL 结构化查询语言 (Structured Query 查询 Language) picks out the records 记录 you want.
- A few keywords do almost everything at IGCSE.
- Read a query in a fixed order to work out its output.
SELECT, FROM, WHERE
SELECT FirstName, FormClass
FROM Student
WHERE FeesPaid = TRUE;
SELECT= which fields 字段 to show (use*for all).FROM= which table.WHERE= a condition 条件, so only matching records appear.

Run a SELECT … WHERE query
WHERE filters the rows to those that match; SELECT then keeps only the columns you chose. Step through to watch the table shrink to the query's answer.
In an SQL query, SELECT specifies:
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
SELECT chooses the fields; FROM the table; WHERE the rows; ORDER BY the sort.
The WHERE clause:
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
WHERE filters rows by a condition.
ORDER BY, AND, OR
SELECT FirstName, DateOfBirth
FROM Student
WHERE FormClass = '10A' AND FeesPaid = FALSE
ORDER BY DateOfBirth ASC;
ORDER BYsorts:ASC(smallest/A→Z first) orDESC(largest/Z→A first).- Join conditions with
AND(both true) orOR(at least one true).
ORDER BY mark DESC sorts the results:
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
DESC = descending (largest/Z→A first); ASC = ascending.
SUM, COUNT, and reading order
COUNTcounts matching records;SUMadds up a number field.- To work out a query's output, read it in this order:
- FROM (which table) → WHERE (keep matching rows) → SELECT (show chosen fields) → ORDER BY (sort).
SELECT COUNT(StudentID) FROM Student WHERE FeesPaid = FALSE;

Match each SQL keyword to what it does.
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
SELECT picks columns, WHERE filters rows, ORDER BY sorts, COUNT tallies the matching rows.
Put the SQL clauses in the order you read them to find the output.
难度 3/5 · 今日首次完成可获 200 金币及少量额外奖励
FROM → WHERE → SELECT → ORDER BY gives you exactly which rows and columns appear.
Worked example: read a query's output
Table Student: (1, Amy, 16, 10A), (2, Ben, 15, 10B), (3, Cara, 17, 10A), with fields StudentID, Name, Age, Form. What does this query output?
SELECT Name, Age FROM Student WHERE Form = "10A" ORDER BY Age DESC;
- FROM Student, WHERE Form = "10A" keeps Amy and Cara. SELECT shows only the Name and Age fields.
- ORDER BY Age DESC sorts from oldest to youngest: Cara 17, then Amy 16.
Using the same table, what does SELECT COUNT(StudentID) FROM Student WHERE Age >= 16; output?
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Amy (16) and Cara (17) match, so the count is 2.
Which query adds up the ages of all students?
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
SUM adds a number field; COUNT counts records.
You've got it
SELECT(fields) ·FROM(table) ·WHERE(condition);*= all fieldsORDER BY … ASC/DESCsorts;AND/ORjoin conditionsCOUNTcounts rows;SUMtotals a number field- read a query: FROM → WHERE → SELECT → ORDER BY