SHARE
TWEET

Untitled

a guest May 23rd, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ### Récupère tous les champs pour les sorciers nés entre 1975 et 1985
  2.  
  3.  
  4. mysql> SELECT * from wizard WHERE birthday > "1975-01-01" AND birthday < "1985-12-31" AND is_muggle = 0;
  5. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  6. | id | firstname | lastname | birthday   | birth_place | biography                             | is_muggle |
  7. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  8. |  1 | harry     | potter   | 1980-07-31 | london      |                                       |         0 |
  9. |  2 | hermione  | granger  | 1979-09-19 |             | Friend of Harry Potter                |         0 |
  10. |  4 | ron       | weasley  | 1980-03-01 |             | Best friend of Harry                  |         0 |
  11. |  5 | ginny     | weasley  | 1981-08-11 |             | Sister of Ron and girlfriend of Harry |         0 |
  12. |  6 | fred      | weasley  | 1978-04-01 |             |                                       |         0 |
  13. |  7 | george    | weasley  | 1978-04-01 |             |                                       |         0 |
  14. | 10 | drago     | malefoy  | 1980-06-05 |             |                                       |         0 |
  15. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  16. 8 rows in set (0.00 sec)
  17.  
  18.  
  19.  
  20. ### Le prénom uniquement des sorciers dont le prénom commence par la lettre ‘H’
  21.  
  22.  
  23. mysql> SELECT * from wizard WHERE firstname REGEXP '(^h+)';
  24. +----+-----------+----------+------------+-------------+------------------------+-----------+
  25. | id | firstname | lastname | birthday   | birth_place | biography              | is_muggle |
  26. +----+-----------+----------+------------+-------------+------------------------+-----------+
  27. |  1 | harry     | potter   | 1980-07-31 | london      |                        |         0 |
  28. |  2 | hermione  | granger  | 1979-09-19 |             | Friend of Harry Potter |         0 |
  29. +----+-----------+----------+------------+-------------+------------------------+-----------+
  30. 2 rows in set (0.00 sec)
  31.  
  32.  
  33.  
  34. ### Les prénom et nom de tous les membres de la famille ‘Potter’, classés par ordre de prénom
  35.  
  36.  
  37. mysql> SELECT * from wizard WHERE lastname = 'potter' ORDER BY firstname ASC;
  38. +----+-----------+----------+------------+-------------+------------------------+-----------+
  39. | id | firstname | lastname | birthday   | birth_place | biography              | is_muggle |
  40. +----+-----------+----------+------------+-------------+------------------------+-----------+
  41. |  1 | harry     | potter   | 1980-07-31 | london      |                        |         0 |
  42. |  3 | lily      | potter   | 1960-01-30 |             | mother of Harry Potter |         0 |
  43. +----+-----------+----------+------------+-------------+------------------------+-----------+
  44. 2 rows in set (0.00 sec)
  45.  
  46.  
  47.  
  48. ### Le prénom, nom et date de naissance du plus vieux sorcier (doit fonctionner quelque soit le contenu de la table)
  49.  
  50.  
  51. mysql> SELECT firstname, lastname, birthday from wizard ORDER BY birthday ASC LIMIT 1;
  52. +-----------+------------+------------+
  53. | firstname | lastname   | birthday   |
  54. +-----------+------------+------------+
  55. | albus     | dumbledore | 1881-07-01 |
  56. +-----------+------------+------------+
  57. 1 row in set (0.00 sec)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top