Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Récupère tous les champs pour les sorciers nés entre 1975 et 1985
- mysql> SELECT * from wizard WHERE birthday > "1975-01-01" AND birthday < "1985-12-31" AND is_muggle = 0;
- +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
- | id | firstname | lastname | birthday | birth_place | biography | is_muggle |
- +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
- | 1 | harry | potter | 1980-07-31 | london | | 0 |
- | 2 | hermione | granger | 1979-09-19 | | Friend of Harry Potter | 0 |
- | 4 | ron | weasley | 1980-03-01 | | Best friend of Harry | 0 |
- | 5 | ginny | weasley | 1981-08-11 | | Sister of Ron and girlfriend of Harry | 0 |
- | 6 | fred | weasley | 1978-04-01 | | | 0 |
- | 7 | george | weasley | 1978-04-01 | | | 0 |
- | 10 | drago | malefoy | 1980-06-05 | | | 0 |
- +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
- 8 rows in set (0.00 sec)
- ### Le prénom uniquement des sorciers dont le prénom commence par la lettre ‘H’
- mysql> SELECT * from wizard WHERE firstname REGEXP '(^h+)';
- +----+-----------+----------+------------+-------------+------------------------+-----------+
- | id | firstname | lastname | birthday | birth_place | biography | is_muggle |
- +----+-----------+----------+------------+-------------+------------------------+-----------+
- | 1 | harry | potter | 1980-07-31 | london | | 0 |
- | 2 | hermione | granger | 1979-09-19 | | Friend of Harry Potter | 0 |
- +----+-----------+----------+------------+-------------+------------------------+-----------+
- 2 rows in set (0.00 sec)
- ### Les prénom et nom de tous les membres de la famille ‘Potter’, classés par ordre de prénom
- mysql> SELECT * from wizard WHERE lastname = 'potter' ORDER BY firstname ASC;
- +----+-----------+----------+------------+-------------+------------------------+-----------+
- | id | firstname | lastname | birthday | birth_place | biography | is_muggle |
- +----+-----------+----------+------------+-------------+------------------------+-----------+
- | 1 | harry | potter | 1980-07-31 | london | | 0 |
- | 3 | lily | potter | 1960-01-30 | | mother of Harry Potter | 0 |
- +----+-----------+----------+------------+-------------+------------------------+-----------+
- 2 rows in set (0.00 sec)
- ### Le prénom, nom et date de naissance du plus vieux sorcier (doit fonctionner quelque soit le contenu de la table)
- mysql> SELECT firstname, lastname, birthday from wizard ORDER BY birthday ASC LIMIT 1;
- +-----------+------------+------------+
- | firstname | lastname | birthday |
- +-----------+------------+------------+
- | albus | dumbledore | 1881-07-01 |
- +-----------+------------+------------+
- 1 row in set (0.00 sec)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement