Skip to content

Instantly share code, notes, and snippets.

@mehdihettak
Created May 27, 2019 11:00
Show Gist options
  • Save mehdihettak/c06b442b5a3f311646c06678eecd096d to your computer and use it in GitHub Desktop.
Save mehdihettak/c06b442b5a3f311646c06678eecd096d to your computer and use it in GitHub Desktop.
mysql> SELECT lastname,firstname,role,name FROM wizard LEFT JOIN player ON wizard.id=player.wizard_id LEFT JOIN team ON team.id=player.team_id ORDER BY name ASC,role,lastname,firstname;
+-----------------+-------------+--------+------------+
| lastname | firstname | role | name |
+-----------------+-------------+--------+------------+
| | Crabbe | NULL | NULL |
| Boot | Terry | NULL | NULL |
| Lupin | Remus | NULL | NULL |
| Patil | Padma | NULL | NULL |
| Patil | Parvati | NULL | NULL |
| Robins | Demelza | NULL | NULL |
| Slughorn | Horace | NULL | NULL |
| Weasley | Charles | NULL | NULL |
| Weasley | Molly | NULL | NULL |
| Black | Sirius | beater | Gryffindor |
| Brown | Lavender | beater | Gryffindor |
| Finnigan | Seamus | beater | Gryffindor |
| Hagrid | Rubeus | beater | Gryffindor |
| Longbottom | Alice | beater | Gryffindor |
| McGonagall | Minerva | beater | Gryffindor |
| Potter | Harry | beater | Gryffindor |
| Potter | James | beater | Gryffindor |
| Thomas | Dean | beater | Gryffindor |
| Weasley | Arthur | beater | Gryffindor |
| Weasley | Percy | beater | Gryffindor |
| Bell | Katie | chaser | Gryffindor |
| Dumbledore | Albus | chaser | Gryffindor |
| Granger | Hermione | chaser | Gryffindor |
| J. | Lily | chaser | Gryffindor |
| Jordan | Lee | chaser | Gryffindor |
| Longbottom | Augusta | chaser | Gryffindor |
| Longbottom | Frank | chaser | Gryffindor |
| Longbottom | Neville | chaser | Gryffindor |
| Pettigrew | Peter | chaser | Gryffindor |
| Spinnet | Alicia | chaser | Gryffindor |
| Weasley | George | chaser | Gryffindor |
| Wood | Oliver | chaser | Gryffindor |
| | Cadogan | keeper | Gryffindor |
| Creevey | Dennis | keeper | Gryffindor |
| de | Nicholas | keeper | Gryffindor |
| Dumbledore | Aberforth | keeper | Gryffindor |
| Johnson | Angelina | keeper | Gryffindor |
| Weasley | Ginevra | keeper | Gryffindor |
| Binns | Cuthbert | seeker | Gryffindor |
| Creevey | Colin | seeker | Gryffindor |
| Gryffindor | Godric | seeker | Gryffindor |
| Vane | Romilda | seeker | Gryffindor |
| Weasley | Fred | seeker | Gryffindor |
| Weasley | Ronald | seeker | Gryffindor |
| Weasley | William | seeker | Gryffindor |
| Abbott | Hannah | beater | Hufflepuff |
| Finch-Fletchley | Justin | beater | Hufflepuff |
| Friar | Fat | beater | Hufflepuff |
| Smith | Hepzibah | beater | Hufflepuff |
| Sprout | Pomona | beater | Hufflepuff |
| Tonks | Nymphadora | beater | Hufflepuff |
| Bones | Amelia | chaser | Hufflepuff |
| Scamander | Newton | chaser | Hufflepuff |
| Bones | Susan | keeper | Hufflepuff |
| Diggory | Cedric | keeper | Hufflepuff |
| Smith | Zacharias | keeper | Hufflepuff |
| Hufflepuff | Helga | seeker | Hufflepuff |
| Clearwater | Penelope | beater | Ravenclaw |
| Quirrell | Quirinus | beater | Ravenclaw |
| Ravenclaw | Helena | beater | Ravenclaw |
| Warren | Myrtle | beater | Ravenclaw |
| Chang | Cho | chaser | Ravenclaw |
| Edgecombe | Marietta | chaser | Ravenclaw |
| Flitwick | Filius | chaser | Ravenclaw |
| Goldstein | Anthony | chaser | Ravenclaw |
| Lockhart | Gilderoy | chaser | Ravenclaw |
| Lovegood | Luna | chaser | Ravenclaw |
| Lovegood | Xenophilius | chaser | Ravenclaw |
| Ollivander | Garrick | chaser | Ravenclaw |
| Corner | Michael | seeker | Ravenclaw |
| Ravenclaw | Rowena | seeker | Ravenclaw |
| Trelawney | Sybill | seeker | Ravenclaw |
| Bulstrode | Millicent | beater | Slytherin |
| Crabbe | Vincent | beater | Slytherin |
| Flint | Marcus | beater | Slytherin |
| Parkinson | Pansy | beater | Slytherin |
| Snape | Severus | beater | Slytherin |
| Zabini | Blaise | beater | Slytherin |
| Baron | Bloody | chaser | Slytherin |
| Lestrange | Bellatrix | chaser | Slytherin |
| Lestrange | Rodolphus | chaser | Slytherin |
| Malfoy | Draco | chaser | Slytherin |
| Malfoy | Lucius | chaser | Slytherin |
| Nigellus | Phineas | chaser | Slytherin |
| Nott | Theodore | chaser | Slytherin |
| Riddle | Tom | chaser | Slytherin |
| Tonks | Andromeda | chaser | Slytherin |
| Black | Regulus | keeper | Slytherin |
| Goyle | Gregory | seeker | Slytherin |
| Lestrange | Rabastan | seeker | Slytherin |
| Malfoy | Narcissa | seeker | Slytherin |
| Slytherin | Salazar | seeker | Slytherin |
| Umbridge | Dolores | seeker | Slytherin |
+-----------------+-------------+--------+------------+
93 rows in set (0.00 sec)
mysql> SELECT lastname,firstname,role FROM wizard LEFT JOIN player ON wizard.id=player.wizard_id WHERE role="seeker";
+------------+-----------+--------+
| lastname | firstname | role |
+------------+-----------+--------+
| Binns | Cuthbert | seeker |
| Corner | Michael | seeker |
| Creevey | Colin | seeker |
| Goyle | Gregory | seeker |
| Gryffindor | Godric | seeker |
| Hufflepuff | Helga | seeker |
| Lestrange | Rabastan | seeker |
| Malfoy | Narcissa | seeker |
| Ravenclaw | Rowena | seeker |
| Slytherin | Salazar | seeker |
| Trelawney | Sybill | seeker |
| Umbridge | Dolores | seeker |
| Vane | Romilda | seeker |
| Weasley | William | seeker |
| Weasley | Fred | seeker |
| Weasley | Ronald | seeker |
+------------+-----------+--------+
16 rows in set (0.00 sec)
mysql> SELECT lastname,firstname FROM wizard LEFT JOIN player ON wizard.id=player.wizard_id LEFT JOIN team ON team.id=player.team_id WHERE player.role IS NULL ORDER BY lastname,firstname;
+----------+-----------+
| lastname | firstname |
+----------+-----------+
| | Crabbe |
| Boot | Terry |
| Lupin | Remus |
| Patil | Padma |
| Patil | Parvati |
| Robins | Demelza |
| Slughorn | Horace |
| Weasley | Charles |
| Weasley | Molly |
+----------+-----------+
9 rows in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment