SQL Basics
Aligned to the OCR J277 specification
- Level
- Intermediate
- Reading time
- 6 min
- Published
- 11 June 2026
- Updated
- 1 July 2026
On this page
Key takeaways
- SQL uses SELECT to choose columns, FROM to choose the table, and WHERE to filter rows; these three keywords form the core of every query required by OCR J277.
- SELECT * returns all columns from every row in the table; add a WHERE clause to limit which rows are returned.
- String values in WHERE conditions must be enclosed in quotes (WHERE Name = "Alice"), but numbers must not (WHERE Age = 16).
- AND narrows results (both conditions must be true); OR broadens results (at least one condition must be true).
Studying this for an exam?
Generate a personalised learning path for this subject. Free to get started.
Key terms
- SQL
- Structured Query Language - a language used to search and retrieve data from a database using keywords such as SELECT, FROM, and WHERE.
- SELECT
- The SQL keyword that specifies which columns to retrieve from a table; SELECT * returns all columns.
- FROM
- The SQL keyword that specifies which table to search.
- WHERE
- The SQL keyword that filters rows by a condition; only rows where the condition is true are returned.
- AND
- A SQL logical operator that requires both conditions to be true; it narrows the number of rows returned.
- OR
- A SQL logical operator that requires at least one condition to be true; it broadens the number of rows returned.
- Table
- In a database, a structured set of data organised into rows (records) and columns (fields).
- Query
- A SQL statement that retrieves data matching specified criteria from a database table.
Frequently asked questions
SELECT * means select all columns. It returns every field for every row in the table (unless a WHERE clause filters the rows). It does not mean all rows - filtering rows is done with WHERE.
Use AND when both conditions must be true, which narrows the results. Use OR when at least one condition must be true, which broadens the results. WHERE Subject = "Maths" AND Subject = "Science" returns zero rows because no row can satisfy both at once.
Wrap the text value in quotes: WHERE Name = "Alice" or WHERE Grade = "A". Without quotes the database treats the value as a column name, which causes an error. Numbers do not use quotes: WHERE Age = 16.
Generate revision on any topic you study
Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.
Lessons on anything
Structured, level-matched lessons on any topic you study
Practice quizzes
Find out what you actually know before the exam does
Flashcard sets
Lock in key concepts with instant revision cards
Ask Aica
Stuck on something? Get a clear explanation, any time
Arrays and Records
Subroutines and Scope
Related lessons
7 min
6 min
9 min