Skip to content

Instantly share code, notes, and snippets.

@mathie
Last active April 22, 2016 05:14
Show Gist options
  • Save mathie/c3447a0a6afc695f851ae9a8360c2ef2 to your computer and use it in GitHub Desktop.
Save mathie/c3447a0a6afc695f851ae9a8360c2ef2 to your computer and use it in GitHub Desktop.
Let’s say we wanted to find out which room a computer was in...
SELECT buildings.name building, floors.name floor, rooms.name room
FROM computers, locations buildings, locations floors, locations rooms
WHERE computers.name = ‘Arabica’
AND computers.room_id = rooms.id
AND rooms.location_id = floors.id
AND floors.location_id = buildings.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment