Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysql> SHOW DATABASES;
- +--------------------+
- | Database |
- +--------------------+
- | blog |
- | checkpoint1 |
- | formulaire_login |
- | information_schema |
- | mysql |
- | new_schema |
- | performance_schema |
- | sys |
- | trombino |
- | wild_db_quest |
- +--------------------+
- 10 rows in set (0,01 sec)
- mysql> USE wild_db_quest;
- Reading table information for completion of table and column names
- You can turn off this feature to get a quicker startup with -A
- Database changed
- mysql> SHOW TABLES;
- +-------------------------+
- | Tables_in_wild_db_quest |
- +-------------------------+
- | player |
- | school |
- | team |
- | wizard |
- +-------------------------+
- 4 rows in set (0,01 sec)
- mysql> SELECT team.name, COUNT(player.id)
- -> FROM player JOIN team ON team.id = player.team_id
- -> GROUP BY team.name
- -> ORDER BY COUNT(player.id) DESC;
- +------------+------------------+
- | name | COUNT(player.id) |
- +------------+------------------+
- | Gryffindor | 36 |
- | Slytherin | 21 |
- | Ravenclaw | 15 |
- | Hufflepuff | 12 |
- +------------+------------------+
- 4 rows in set (0,00 sec)
- mysql> SELECT team.name
- -> FROM player JOIN team ON team.id = player.team_id
- -> GROUP BY team.name
- -> HAVING COUNT(player.id) > 14
- -> ORDER BY name;
- +------------+
- | name |
- +------------+
- | Gryffindor |
- | Ravenclaw |
- | Slytherin |
- +------------+
- 3 rows in set (0,00 sec)
- mysql> SELECT wizard.firstname, wizard.lastname, player.enrollement_date
- -> FROM player JOIN wizard ON wizard.id = player.wizard_id
- -> JOIN team ON team.id = player.team_id
- -> WHERE DAYOFWEEK(player.enrollement_date) = 2 AND team.id =1
- -> ORDER BY enrollement_date;
- +-----------+------------+------------------+
- | firstname | lastname | enrollement_date |
- +-----------+------------+------------------+
- | George | Weasley | 1991-08-26 |
- | Alice | Longbottom | 1992-02-17 |
- | Cadogan | | 1993-01-04 |
- | Godric | Gryffindor | 1993-08-30 |
- | Sirius | Black | 1994-01-10 |
- | Aberforth | Dumbledore | 1995-04-24 |
- | Augusta | Longbottom | 1999-10-25 |
- +-----------+------------+------------------+
- 7 rows in set (0,00 sec)
- mysql>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement