The use of SQL to search for data
2.2.3 Additional Programming Techniques
Practise exam questionsAdditional Programming Techniques — Note 5 of 12
SQL commands:SELECT, FROM, WHERE
SQL (Structured Query Language) is used to search for, manage, and retrieve data from a database. The three key SQL commands you need to know are SELECT (which fields to return), FROM (which table to search), and WHERE (which conditions to apply). You can select specific fields, multiple fields, or all fields using the wildcard *.
WHERE YearGroup = 11.SELECT * returns ALL fields from the table.WHERE DroneType = "Octocopter" AND Mileage > 50000.= for comparison in SQL (not ==, although == is accepted in some exam mark schemes).An organised collection of related data stored in tables that allows data to be easily accessed, managed and queried.
SELECT * or list all field names separated by commas.WHERE SensorType = "Door". Numeric values don't need quotes: WHERE Mileage > 50000.WHERE SensorType = "Door" AND Length > 20.-- Get all unsold cars
SELECT Model
FROM Cars
WHERE Sold = FALSE
-- Get multiple fields with conditions
SELECT Model, Manufacturer, Price
FROM Cars
WHERE Sold = TRUE AND Price > 4000
-- Get all fields for Ford cars
SELECT *
FROM Cars
WHERE Manufacturer = 'Ford'Ready to test yourself?
Practise 2.2.3 questions