Advertisement
Sora952

Wizard sort (sort... ilège !...)

May 15th, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 5.30 KB | None | 0 0
  1. mysql> SELECT * FROM wizard WHERE lastname='Weasley' ORDER BY birthday DESC LIMIT 0,3;
  2. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  3. | id | firstname | lastname | birthday   | birth_place | biography                             | is_muggle |
  4. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  5. |  5 | ginny     | weasley  | 1981-08-11 |             | Sister of Ron and girlfriend of Harry |         0 |
  6. | 19 | ginny     | weasley  | 1981-08-11 |             | Sister of Ron and girlfriend of Harry |         0 |
  7. |  4 | ron       | weasley  | 1980-03-01 |             | Best friend of Harry                  |         0 |
  8. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  9. 3 rows in set (0.00 sec)
  10.  
  11. mysql> SELECT * FROM wizard  WHERE birthday BETWEEN '1970-01-01' AND '2000-01-01';
  12. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  13. | id | firstname | lastname | birthday   | birth_place | biography                             | is_muggle |
  14. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  15. |  1 | harry     | potter   | 1980-07-31 | london      |                                       |         0 |
  16. |  2 | hermione  | granger  | 1979-09-19 |             | Friend of Harry Potter                |         0 |
  17. |  4 | ron       | weasley  | 1980-03-01 |             | Best friend of Harry                  |         0 |
  18. |  5 | ginny     | weasley  | 1981-08-11 |             | Sister of Ron and girlfriend of Harry |         0 |
  19. |  6 | fred      | weasley  | 1978-04-01 |             |                                       |         0 |
  20. |  7 | george    | weasley  | 1978-04-01 |             |                                       |         0 |
  21. | 10 | drago     | malefoy  | 1980-06-05 |             |                                       |         0 |
  22. | 14 | dudley    | dursley  | 1980-06-23 |             | Cousin d'Harry                        |         1 |
  23. | 15 | harry     | potter   | 1980-07-31 | london      |                                       |         0 |
  24. | 16 | hermione  | granger  | 1979-09-19 |             | Friend of Harry Potter                |         0 |
  25. | 18 | ron       | weasley  | 1980-03-01 |             | Best friend of Harry                  |         0 |
  26. | 19 | ginny     | weasley  | 1981-08-11 |             | Sister of Ron and girlfriend of Harry |         0 |
  27. | 20 | fred      | weasley  | 1978-04-01 |             |                                       |         0 |
  28. | 21 | george    | weasley  | 1978-04-01 |             |                                       |         0 |
  29. | 24 | drago     | malefoy  | 1980-06-05 |             |                                       |         0 |
  30. | 28 | dudley    | dursley  | 1980-06-23 |             | Cousin d'Harry                        |         1 |
  31. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  32. 16 rows in set (0.00 sec)
  33.  
  34.  
  35.  
  36.  
  37. mysql> SELECT firstname FROM wizard  WHERE  firstname LIKE 'H%';
  38. +-----------+
  39. | firstname |
  40. +-----------+
  41. | harry     |
  42. | hermione  |
  43. | harry     |
  44. | hermione  |
  45. +-----------+
  46. 4 rows in set (0.00 sec)
  47.  
  48.  
  49.  
  50. mysql> SELECT firstname, lastname FROM wizard WHERE lastname='potter' ORDER BY firstname;
  51. +-----------+----------+
  52. | firstname | lastname |
  53. +-----------+----------+
  54. | harry     | potter   |
  55. | harry     | potter   |
  56. | lily      | potter   |
  57. | lily      | potter   |
  58. +-----------+----------+
  59. 4 rows in set (0.00 sec)
  60.  
  61. mysql>
  62.  
  63.  
  64. mysql> SELECT firstname, lastname, birthday FROM wizard ORDER BY birthday ASC LIMIT 1;
  65. +-----------+------------+------------+
  66. | firstname | lastname   | birthday   |
  67. +-----------+------------+------------+
  68. | albus     | dumbledore | 1881-07-01 |
  69. +-----------+------------+------------+
  70. 1 row in set (0.00 sec)
  71.  
  72. mysql>
  73.  
  74. mysql> SELECT * FROM wizard WHERE (birthday BETWEEN '1975-01-01' AND '1985-12-31') AND is_muggle = 0 ;
  75. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  76. | id | firstname | lastname | birthday   | birth_place | biography                             | is_muggle |
  77. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  78. |  1 | harry     | potter   | 1980-07-31 | london      |                                       |         0 |
  79. |  2 | hermione  | granger  | 1979-09-19 |             | Friend of Harry Potter                |         0 |
  80. |  4 | ron       | weasley  | 1980-03-01 |             | Best friend of Harry                  |         0 |
  81. |  5 | ginny     | weasley  | 1981-08-11 |             | Sister of Ron and girlfriend of Harry |         0 |
  82. |  6 | fred      | weasley  | 1978-04-01 |             |                                       |         0 |
  83. |  7 | george    | weasley  | 1978-04-01 |             |                                       |         0 |
  84. | 10 | drago     | malefoy  | 1980-06-05 |             |                                       |         0 |
  85. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  86. 7 rows in set (0.00 sec)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement