Skip to content

Instantly share code, notes, and snippets.

@MostlyFocusedMike
Last active April 29, 2018 04:48
Show Gist options
  • Save MostlyFocusedMike/a1c832732a81f0ce273affb7fb7184c9 to your computer and use it in GitHub Desktop.
Save MostlyFocusedMike/a1c832732a81f0ce273affb7fb7184c9 to your computer and use it in GitHub Desktop.
SELECT cats.name AS cat, owners.name AS owner |P | SELECT *
FROM owners |R | FROM owners
INNER JOIN cats_owners |E | INNER JOIN cats_owners
ON owners.id = cats_owners.owner_id |V | ON owners.id = cats_owners.owner_id;
INNER JOIN cats |I |
ON cats_owners.cat_id = cats.id; |O | # which returned:
|U |
# returns this: |S ->| id name cat_id owner_id
| | ---------- ---------- ---------- ----------
cat owner |L | 2 Sophie 3 2
---------- ---------- |A | 3 Penny 3 3
Grumpy Cat Sophie |Y | 2 Sophie 1 2
Grumpy Cat Penny |E |
Maru Sophie |R |
| |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment