Theory Notes/🗄️ Topic 5: Data and Information Management/11.5.1
11.5.1Grade 11

Database Management: Querying with SQL

SQL is how you ask a database questions. Grade 11 covers retrieving and filtering data from a single table; Grade 12 adds joins and aggregates.

Every query is built from the same clauses, and they must appear in this order:

ClausePurposeExample
SELECTWhich fields to showSELECT FirstName, Surname
FROMWhich tableFROM tblLearners
WHEREWhich records to includeWHERE Grade = 11
ORDER BYHow to sort the resultORDER BY Surname ASC

Example

SELECT FirstName, Surname, Grade FROM tblLearners WHERE Grade = 11 AND Gender = 'F' ORDER BY Surname ASC;

OperatorMeaningExample
= <> < > <= >=ComparisonWHERE Mark >= 50
AND / OR / NOTCombine conditionsWHERE Grade = 11 AND Mark > 60
LIKE with % and _Pattern matchWHERE Surname LIKE 'B%'
BETWEEN … ANDInclusive rangeWHERE Mark BETWEEN 50 AND 74
IN (…)Any of a listWHERE Grade IN (10, 11)
IS NULLNo value storedWHERE Email IS NULL

You can also create a calculated field in the SELECT list and name it with AS. The memo expects the exact name the question asked for.

Example

SELECT Description, Price, Price * 1.15 AS PriceWithVAT FROM tblStock;

💡 Exam Tip

Text literals go in single quotes ('F'); numbers do not. And % matches any number of characters while _ matches exactly one — 'B%' is 'starts with B', '_B%' is 'B is the second letter'.