Signed up recently but had issues with the confirmation email?
Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.
Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.
SQL – Interpret and modify. See appendix 5d.
1.3.2 Databases
Practise exam questionsDatabases — Note 4 of 6
Candidates should have experience of using SQL to edit and modify data in a database. They should understand the need for SQL as a standard language. Candidates should be able write and follow scripts using the SQL commands listed in appendix 5d.
Structured Query Language (SQL) is the standard language for querying and changing relational databases. You need to be able to read, write and amend SQL using the commands in appendix 5d.
SELECT chooses the fields to return; FROM names the table(s); WHERE filters records using conditions. To describe what a query does, say which fields it returns, from which table, for which records, and give the results if data is shown.AND / OR combine conditions. LIKE matches patterns, using % as a wildcard for any number of characters. * after SELECT returns all fields.JOIN combines records from two tables where a field matches (equivalent to INNER JOIN; outer joins are not required).SELECT: a query can be used inside another query's WHERE clause.INSERT INTO ... VALUES adds a record; DELETE FROM ... WHERE removes records; DROP TABLE deletes a whole table and its data.-- Fields from one table with conditions
SELECT FirstName, Surname
FROM Students
WHERE Year = 12 AND Surname LIKE 'S%'
-- Join two tables on a shared key
SELECT Students.Surname, Classes.Room
FROM Students
JOIN Classes ON Students.ClassID = Classes.ClassID
-- Nested SELECT
SELECT Surname FROM Students
WHERE ClassID IN (SELECT ClassID FROM Classes WHERE Room = 'C4')
-- Add, remove and drop
INSERT INTO Students (StudentID, FirstName, Surname, Year)
VALUES (1042, 'Sam', 'Patel', 12)
DELETE FROM Students WHERE StudentID = 1042
DROP TABLE OldResultsA declarative language used to define, query and manipulate data in relational databases.
SELECT * loses the mark when specific fields are wanted. Compare with a single =, never ==.DELETE FROM Students without a WHERE clause, which deletes EVERY record.DELETE * FROM Students or listing fields after DELETE. DELETE removes whole records, so it takes no * or field names: DELETE FROM Students WHERE StudentID = 1042.JOIN ... ON, or a WHERE matching the foreign key to the primary key) or use a nested SELECT. Prefix field names with their table name, e.g. Students.ClassID. Pick ONE of these methods for the whole query: marks from different methods are not added together. If two tables only connect through a link table, join each pair on its shared key, e.g. Students to Enrolments on StudentID, then Enrolments to Courses on CourseID.UPDATE is not in appendix 5d but has been asked for, so learn its form: UPDATE Students SET Year = 13 WHERE StudentID = 1042. Other commands (e.g. ORDER BY) will be explained in the question if needed.Past exam questions
Ready to test yourself?
Practise 1.3.2 questions