Jump to navigation Jump to search
Congestion charging database
ER diagram for the Congestion charging database:
keeper(id, name, address)
image(camera, whn, reg)
permit(reg, sDate, chargeType)
List the vehicles for which 'Strenuous, Sam' is the registered keeper. The link between Keepers and Vehicles is via the foreign key specified in the CREATE TABLE vehicle statement. Note the line:
,FOREIGN KEY(keeper) REFERENCES keeper(id)
This will be the basis of our join condition.
SELECT vehicle.id FROM vehicle JOIN keeper ON vehicle.keeper = keeper.id WHERE keeper.name = 'Strenuous, Sam'