This topic summary covers Knowledge Organiser: SQL within SQL for GCSE Computer Science. Revise SQL in Programming for GCSE Computer Science with 15 exam-style questions and 10 flashcards. This topic appears regularly enough that it should still be part of a steady revision cycle. It is section 9 of 9 in this topic. Use this topic summary to connect the idea to the wider topic before moving on to questions and flashcards.
Topic position
Section 9 of 9
Practice
15 questions
Recall
10 flashcards
Knowledge Organiser: SQL
Key Terms
- SQL: Structured Query Language — used to query and manage databases
- SELECT: Specifies which columns to retrieve
- FROM: Specifies the table to query
- WHERE: Filters rows by a condition
- ORDER BY: Sorts the results (ASC = ascending, DESC = descending)
- Wildcard (*): Selects all columns in a table
Must-Know Facts
- SQL keyword order: SELECT ... FROM ... WHERE ... ORDER BY
- String values in WHERE must be in quotes:
WHERE city = "London" - Number values do not use quotes:
WHERE age > 16 - Use AND to require multiple conditions; use OR for either condition
SELECT *returns all columns; name specific columns to limit output- ASC sorts lowest to highest; DESC sorts highest to lowest
Key Concepts
- Get all data:
SELECT * FROM Students - Filter rows:
SELECT name FROM Students WHERE age > 16 - Sort results:
ORDER BY score DESC - Multiple conditions:
WHERE age >= 16 AND city = "London" - Memory aid: S-F-W-O — Select, From, Where, Order by
Common Mistakes
- Getting the SQL keyword order wrong: The correct order is SELECT ... FROM ... WHERE ... ORDER BY — putting WHERE before FROM will cause a syntax error
- Forgetting quotes around string values: String comparisons in WHERE require quotes:
WHERE name = "Ali"; numeric comparisons do not:WHERE age > 16 - Using = instead of > or < for numeric ranges:
WHERE age = 16only matches exactly 16; use>=or<=for ranges - Forgetting ORDER BY comes last: ORDER BY must appear after WHERE — placing it in the middle causes a syntax error
- Confusing AND and OR in WHERE clauses: AND requires both conditions to be true; OR requires at least one — mixing them up produces incorrect results
Revise this topic interactively on PrepWise — self-test mode, tap-to-reveal definitions, and Common Mistakes from examiners.
Try the interactive Knowledge Organiser — free →