Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select t.name team_name, p.role, w.lastname, w.firstname FROM player p JOIN team t ON t.id=p.team_id JOIN wizard w ON w.id=p.wizard_id ORDER BY t.name;
- +------------+--------+-----------------+-------------+
- | team_name | role | lastname | firstname |
- +------------+--------+-----------------+-------------+
- | Gryffindor | chaser | Bell | Katie |
- | Gryffindor | seeker | Binns | Cuthbert |
- | Gryffindor | beater | Black | Sirius |
- | Gryffindor | beater | Brown | Lavender |
- | Gryffindor | seeker | Creevey | Colin |
- | Gryffindor | keeper | Creevey | Dennis |
- | Gryffindor | keeper | Dumbledore | Aberforth |
- | Gryffindor | chaser | Dumbledore | Albus |
- | Gryffindor | beater | Finnigan | Seamus |
- | Gryffindor | chaser | Granger | Hermione |
- | Gryffindor | seeker | Gryffindor | Godric |
- | Gryffindor | beater | Hagrid | Rubeus |
- | Gryffindor | keeper | Johnson | Angelina |
- | Gryffindor | chaser | Jordan | Lee |
- | Gryffindor | beater | Longbottom | Alice |
- | Gryffindor | chaser | Longbottom | Frank |
- | Gryffindor | chaser | Longbottom | Augusta |
- | Gryffindor | chaser | Longbottom | Neville |
- | Gryffindor | beater | McGonagall | Minerva |
- | Gryffindor | chaser | Pettigrew | Peter |
- | Gryffindor | beater | Potter | Harry |
- | Gryffindor | beater | Potter | James |
- | Gryffindor | chaser | J. | Lily |
- | Gryffindor | chaser | Spinnet | Alicia |
- | Gryffindor | beater | Thomas | Dean |
- | Gryffindor | seeker | Vane | Romilda |
- | Gryffindor | beater | Weasley | Arthur |
- | Gryffindor | seeker | Weasley | William |
- | Gryffindor | seeker | Weasley | Fred |
- | Gryffindor | chaser | Weasley | George |
- | Gryffindor | keeper | Weasley | Ginevra |
- | Gryffindor | beater | Weasley | Percy |
- | Gryffindor | seeker | Weasley | Ronald |
- | Gryffindor | chaser | Wood | Oliver |
- | Gryffindor | keeper | | Cadogan |
- | Gryffindor | keeper | de | Nicholas |
- | Hufflepuff | beater | Abbott | Hannah |
- | Hufflepuff | chaser | Bones | Amelia |
- | Hufflepuff | keeper | Bones | Susan |
- | Hufflepuff | keeper | Diggory | Cedric |
- | Hufflepuff | beater | Finch-Fletchley | Justin |
- | Hufflepuff | seeker | Hufflepuff | Helga |
- | Hufflepuff | chaser | Scamander | Newton |
- | Hufflepuff | beater | Smith | Hepzibah |
- | Hufflepuff | keeper | Smith | Zacharias |
- | Hufflepuff | beater | Sprout | Pomona |
- | Hufflepuff | beater | Tonks | Nymphadora |
- | Hufflepuff | beater | Friar | Fat |
- | Ravenclaw | chaser | Chang | Cho |
- | Ravenclaw | beater | Clearwater | Penelope |
- | Ravenclaw | seeker | Corner | Michael |
- | Ravenclaw | chaser | Edgecombe | Marietta |
- | Ravenclaw | chaser | Flitwick | Filius |
- | Ravenclaw | chaser | Goldstein | Anthony |
- | Ravenclaw | chaser | Lockhart | Gilderoy |
- | Ravenclaw | chaser | Lovegood | Luna |
- | Ravenclaw | chaser | Lovegood | Xenophilius |
- | Ravenclaw | chaser | Ollivander | Garrick |
- | Ravenclaw | beater | Quirrell | Quirinus |
- | Ravenclaw | beater | Ravenclaw | Helena |
- | Ravenclaw | seeker | Ravenclaw | Rowena |
- | Ravenclaw | seeker | Trelawney | Sybill |
- | Ravenclaw | beater | Warren | Myrtle |
- | Slytherin | chaser | Nigellus | Phineas |
- | Slytherin | keeper | Black | Regulus |
- | Slytherin | beater | Bulstrode | Millicent |
- | Slytherin | beater | Crabbe | Vincent |
- | Slytherin | beater | Flint | Marcus |
- | Slytherin | seeker | Goyle | Gregory |
- | Slytherin | chaser | Lestrange | Bellatrix |
- | Slytherin | seeker | Lestrange | Rabastan |
- | Slytherin | chaser | Lestrange | Rodolphus |
- | Slytherin | chaser | Malfoy | Draco |
- | Slytherin | chaser | Malfoy | Lucius |
- | Slytherin | seeker | Malfoy | Narcissa |
- | Slytherin | chaser | Nott | Theodore |
- | Slytherin | beater | Parkinson | Pansy |
- | Slytherin | chaser | Riddle | Tom |
- | Slytherin | seeker | Slytherin | Salazar |
- | Slytherin | beater | Snape | Severus |
- | Slytherin | chaser | Tonks | Andromeda |
- | Slytherin | seeker | Umbridge | Dolores |
- | Slytherin | beater | Zabini | Blaise |
- | Slytherin | chaser | Baron | Bloody |
- +------------+--------+-----------------+-------------+
- 84 rows in set (0.01 sec)
- mysql>
- mysql> select w.lastname, w.firstname FROM player p JOIN wizard w ON w.id=p.wizard_id WHERE p.role='seeker' ORDER BY w.lastname, w.firstname;
- +------------+-----------+
- | lastname | firstname |
- +------------+-----------+
- | Binns | Cuthbert |
- | Corner | Michael |
- | Creevey | Colin |
- | Goyle | Gregory |
- | Gryffindor | Godric |
- | Hufflepuff | Helga |
- | Lestrange | Rabastan |
- | Malfoy | Narcissa |
- | Ravenclaw | Rowena |
- | Slytherin | Salazar |
- | Trelawney | Sybill |
- | Umbridge | Dolores |
- | Vane | Romilda |
- | Weasley | Fred |
- | Weasley | Ronald |
- | Weasley | William |
- +------------+-----------+
- 16 rows in set (0.00 sec)
- mysql>
- // SELECT * FROM wizard LEFT JOIN player ON wizard.id = player.wizard_id WHERE player.wizard_id IS NULL; la commande qui fonctionne, ceux d'en dessous c'est des tests
- mysql> select w.lastname, w.firstname, p.role FROM player p RIGHT JOIN wizard w ON w.id=p.wizard_id ORDER BY w.lastname, w.firstname;
- +-----------------+-------------+--------+
- | lastname | firstname | role |
- +-----------------+-------------+--------+
- | | Cadogan | keeper |
- | | Crabbe | NULL |
- | Abbott | Hannah | beater |
- | Baron | Bloody | chaser |
- | Bell | Katie | chaser |
- | Binns | Cuthbert | seeker |
- | Black | Regulus | keeper |
- | Black | Sirius | beater |
- | Bones | Amelia | chaser |
- | Bones | Susan | keeper |
- | Boot | Terry | NULL |
- | Brown | Lavender | beater |
- | Bulstrode | Millicent | beater |
- | Chang | Cho | chaser |
- | Clearwater | Penelope | beater |
- | Corner | Michael | seeker |
- | Crabbe | Vincent | beater |
- | Creevey | Colin | seeker |
- | Creevey | Dennis | keeper |
- | de | Nicholas | keeper |
- | Diggory | Cedric | keeper |
- | Dumbledore | Aberforth | keeper |
- | Dumbledore | Albus | chaser |
- | Edgecombe | Marietta | chaser |
- | Finch-Fletchley | Justin | beater |
- | Finnigan | Seamus | beater |
- | Flint | Marcus | beater |
- | Flitwick | Filius | chaser |
- | Friar | Fat | beater |
- | Goldstein | Anthony | chaser |
- | Goyle | Gregory | seeker |
- | Granger | Hermione | chaser |
- | Gryffindor | Godric | seeker |
- | Hagrid | Rubeus | beater |
- | Hufflepuff | Helga | seeker |
- | J. | Lily | chaser |
- | Johnson | Angelina | keeper |
- | Jordan | Lee | chaser |
- | Lestrange | Bellatrix | chaser |
- | Lestrange | Rabastan | seeker |
- | Lestrange | Rodolphus | chaser |
- | Lockhart | Gilderoy | chaser |
- | Longbottom | Alice | beater |
- | Longbottom | Augusta | chaser |
- | Longbottom | Frank | chaser |
- | Longbottom | Neville | chaser |
- | Lovegood | Luna | chaser |
- | Lovegood | Xenophilius | chaser |
- | Lupin | Remus | NULL |
- | Malfoy | Draco | chaser |
- | Malfoy | Lucius | chaser |
- | Malfoy | Narcissa | seeker |
- | McGonagall | Minerva | beater |
- | Nigellus | Phineas | chaser |
- | Nott | Theodore | chaser |
- | Ollivander | Garrick | chaser |
- | Parkinson | Pansy | beater |
- | Patil | Padma | NULL |
- | Patil | Parvati | NULL |
- | Pettigrew | Peter | chaser |
- | Potter | Harry | beater |
- | Potter | James | beater |
- | Quirrell | Quirinus | beater |
- | Ravenclaw | Helena | beater |
- | Ravenclaw | Rowena | seeker |
- | Riddle | Tom | chaser |
- | Robins | Demelza | NULL |
- | Scamander | Newton | chaser |
- | Slughorn | Horace | NULL |
- | Slytherin | Salazar | seeker |
- | Smith | Hepzibah | beater |
- | Smith | Zacharias | keeper |
- | Snape | Severus | beater |
- | Spinnet | Alicia | chaser |
- | Sprout | Pomona | beater |
- | Thomas | Dean | beater |
- | Tonks | Andromeda | chaser |
- | Tonks | Nymphadora | beater |
- | Trelawney | Sybill | seeker |
- | Umbridge | Dolores | seeker |
- | Vane | Romilda | seeker |
- | Warren | Myrtle | beater |
- | Weasley | Arthur | beater |
- | Weasley | Charles | NULL |
- | Weasley | Fred | seeker |
- | Weasley | George | chaser |
- | Weasley | Ginevra | keeper |
- | Weasley | Molly | NULL |
- | Weasley | Percy | beater |
- | Weasley | Ronald | seeker |
- | Weasley | William | seeker |
- | Wood | Oliver | chaser |
- | Zabini | Blaise | beater |
- +-----------------+-------------+--------+
- 93 rows in set (0.01 sec)
- mysql> select w.lastname, w.firstname, p.role FROM player p RIGHT JOIN wizard w ON w.id=p.wizard_id WHERE p.role=NULL ORDER BY w.lastname, w.firstname;
- Empty set (0.00 sec)
- mysql> SELECT * FROM wizard LEFT JOIN player ON wizard.id = player.wizard_id WHERE player.wizard_id is NULL;
- +----+-----------+----------+------+-----------+---------+------+-----------------+
- | id | firstname | lastname | id | wizard_id | team_id | role | enrollment_date |
- +----+-----------+----------+------+-----------+---------+------+-----------------+
- | 9 | Terry | Boot | NULL | NULL | NULL | NULL | NULL |
- | 15 | Crabbe | | NULL | NULL | NULL | NULL | NULL |
- | 45 | Remus | Lupin | NULL | NULL | NULL | NULL | NULL |
- | 53 | Padma | Patil | NULL | NULL | NULL | NULL | NULL |
- | 54 | Parvati | Patil | NULL | NULL | NULL | NULL | NULL |
- | 63 | Demelza | Robins | NULL | NULL | NULL | NULL | NULL |
- | 65 | Horace | Slughorn | NULL | NULL | NULL | NULL | NULL |
- | 80 | Charles | Weasley | NULL | NULL | NULL | NULL | NULL |
- | 84 | Molly | Weasley | NULL | NULL | NULL | NULL | NULL |
- +----+-----------+----------+------+-----------+---------+------+-----------------+
- 9 rows in set (0.00 sec)
- mysql>
Add Comment
Please, Sign In to add comment