Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.12 KB | None | 0 0
  1. mysql> describe wizard;
  2. +-------------+--------------+------+-----+---------+----------------+
  3. | Field | Type | Null | Key | Default | Extra |
  4. +-------------+--------------+------+-----+---------+----------------+
  5. | id | int(11) | NO | PRI | NULL | auto_increment |
  6. | firstname | varchar(100) | NO | | NULL | |
  7. | lastname | varchar(100) | NO | | NULL | |
  8. | birthday | date | YES | | NULL | |
  9. | birth_place | varchar(255) | YES | | NULL | |
  10. | biography | text | YES | | NULL | |
  11. | is_muggle | tinyint(1) | YES | | NULL | |
  12. +-------------+--------------+------+-----+---------+----------------+
  13. 7 rows in set (0,01 sec)
  14.  
  15. mysql> select * from wizard;
  16. +----+-----------+------------+------------+-------------+-------------------------------------------------------------+-----------+
  17. | id | firstname | lastname | birthday | birth_place | biography | is_muggle |
  18. +----+-----------+------------+------------+-------------+-------------------------------------------------------------+-----------+
  19. | 1 | harry | potter | 1980-07-31 | london | | 0 |
  20. | 2 | hermione | granger | 1979-09-19 | | Friend of Harry Potter | 0 |
  21. | 3 | lily | potter | 1960-01-30 | | mother of Harry Potter | 0 |
  22. | 4 | ron | weasley | 1980-03-01 | | Best friend of Harry | 0 |
  23. | 5 | ginny | weasley | 1981-08-11 | | Sister of Ron and girlfriend of Harry | 0 |
  24. | 6 | fred | weasley | 1978-04-01 | | | 0 |
  25. | 7 | george | weasley | 1978-04-01 | | | 0 |
  26. | 8 | arthur | weasley | 1950-02-06 | | | 0 |
  27. | 9 | molly | weasley | 1949-01-01 | | | 0 |
  28. | 10 | drago | malefoy | 1980-06-05 | | | 0 |
  29. | 11 | albus | dumbledore | 1881-07-01 | | | 0 |
  30. | 12 | severus | rogue | 1960-01-09 | | | 0 |
  31. | 13 | tom | jédusor | 1926-12-31 | | Celui-Dont-On-Ne-Doit-Pas-Prononcer-Le-Nom alias Voldermort | 0 |
  32. | 14 | dudley | dursley | 1980-06-23 | | Cousin d'Harry | 1 |
  33. +----+-----------+------------+------------+-------------+-------------------------------------------------------------+-----------+
  34. 14 rows in set (0,00 sec)
  35.  
  36. mysql> select firstname, lastname from wizard;
  37. +-----------+------------+
  38. | firstname | lastname |
  39. +-----------+------------+
  40. | harry | potter |
  41. | hermione | granger |
  42. | lily | potter |
  43. | ron | weasley |
  44. | ginny | weasley |
  45. | fred | weasley |
  46. | george | weasley |
  47. | arthur | weasley |
  48. | molly | weasley |
  49. | drago | malefoy |
  50. | albus | dumbledore |
  51. | severus | rogue |
  52. | tom | jédusor |
  53. | dudley | dursley |
  54. +-----------+------------+
  55. 14 rows in set (0,01 sec)
  56.  
  57. mysql> select * from wizard where birthday between '1975' and '1985' ;
  58. Empty set, 2 warnings (0,01 sec)
  59.  
  60. mysql> select * from wizard where birthday between '1975-01-01' and '1985-01-01' ;
  61. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  62. | id | firstname | lastname | birthday | birth_place | biography | is_muggle |
  63. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  64. | 1 | harry | potter | 1980-07-31 | london | | 0 |
  65. | 2 | hermione | granger | 1979-09-19 | | Friend of Harry Potter | 0 |
  66. | 4 | ron | weasley | 1980-03-01 | | Best friend of Harry | 0 |
  67. | 5 | ginny | weasley | 1981-08-11 | | Sister of Ron and girlfriend of Harry | 0 |
  68. | 6 | fred | weasley | 1978-04-01 | | | 0 |
  69. | 7 | george | weasley | 1978-04-01 | | | 0 |
  70. | 10 | drago | malefoy | 1980-06-05 | | | 0 |
  71. | 14 | dudley | dursley | 1980-06-23 | | Cousin d'Harry | 1 |
  72. +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
  73. 8 rows in set (0,01 sec)
  74.  
  75. mysql> select firstname from wizard where fistname like 'H%'
  76. -> ;
  77. ERROR 1054 (42S22): Unknown column 'fistname' in 'where clause'
  78. mysql> select firstname from wizard where fistname like 'H%';
  79. ERROR 1054 (42S22): Unknown column 'fistname' in 'where clause'
  80. mysql> select firstname from wizard where fistname like 'H';
  81. ERROR 1054 (42S22): Unknown column 'fistname' in 'where clause'
  82. mysql> select * from wizard where firstname like 'H';
  83. Empty set (0,01 sec)
  84.  
  85. mysql> select * from wizard where firstname like 'H%';
  86. +----+-----------+----------+------------+-------------+------------------------+-----------+
  87. | id | firstname | lastname | birthday | birth_place | biography | is_muggle |
  88. +----+-----------+----------+------------+-------------+------------------------+-----------+
  89. | 1 | harry | potter | 1980-07-31 | london | | 0 |
  90. | 2 | hermione | granger | 1979-09-19 | | Friend of Harry Potter | 0 |
  91. +----+-----------+----------+------------+-------------+------------------------+-----------+
  92. 2 rows in set (0,00 sec)
  93.  
  94. mysql> select firstname, lastname from wizard where lastname='Potter';
  95. +-----------+----------+
  96. | firstname | lastname |
  97. +-----------+----------+
  98. | harry | potter |
  99. | lily | potter |
  100. +-----------+----------+
  101. 2 rows in set (0,01 sec)
  102.  
  103. mysql> select firstname, lastname from wizard where lastname='Potter' order by firstname ;
  104. +-----------+----------+
  105. | firstname | lastname |
  106. +-----------+----------+
  107. | harry | potter |
  108. | lily | potter |
  109. +-----------+----------+
  110. 2 rows in set (0,01 sec)
  111.  
  112. mysql> select * from wizard where lastname='Potter' order by firstname ;
  113. +----+-----------+----------+------------+-------------+------------------------+-----------+
  114. | id | firstname | lastname | birthday | birth_place | biography | is_muggle |
  115. +----+-----------+----------+------------+-------------+------------------------+-----------+
  116. | 1 | harry | potter | 1980-07-31 | london | | 0 |
  117. | 3 | lily | potter | 1960-01-30 | | mother of Harry Potter | 0 |
  118. +----+-----------+----------+------------+-------------+------------------------+-----------+
  119. 2 rows in set (0,00 sec)
  120.  
  121. mysql> select firstname, lastname, birthday from wizard where birthday='birthday desc';
  122. ERROR 1525 (HY000): Incorrect DATE value: 'birthday desc'
  123. mysql> select firstname, lastname, birthday from wizard order by birthday;
  124. +-----------+------------+------------+
  125. | firstname | lastname | birthday |
  126. +-----------+------------+------------+
  127. | albus | dumbledore | 1881-07-01 |
  128. | tom | jédusor | 1926-12-31 |
  129. | molly | weasley | 1949-01-01 |
  130. | arthur | weasley | 1950-02-06 |
  131. | severus | rogue | 1960-01-09 |
  132. | lily | potter | 1960-01-30 |
  133. | fred | weasley | 1978-04-01 |
  134. | george | weasley | 1978-04-01 |
  135. | hermione | granger | 1979-09-19 |
  136. | ron | weasley | 1980-03-01 |
  137. | drago | malefoy | 1980-06-05 |
  138. | dudley | dursley | 1980-06-23 |
  139. | harry | potter | 1980-07-31 |
  140. | ginny | weasley | 1981-08-11 |
  141. +-----------+------------+------------+
  142. 14 rows in set (0,01 sec)
  143.  
  144. mysql> select firstname, lastname, birthday from wizard order by birthday limit 1,1;
  145. +-----------+----------+------------+
  146. | firstname | lastname | birthday |
  147. +-----------+----------+------------+
  148. | tom | jédusor | 1926-12-31 |
  149. +-----------+----------+------------+
  150. 1 row in set (0,00 sec)
  151.  
  152. mysql> select firstname, lastname, birthday from wizard order by birthday limit 1,0;
  153. Empty set (0,00 sec)
  154.  
  155. mysql> select firstname, lastname, birthday from wizard order by birthday limit 0,1;
  156. +-----------+------------+------------+
  157. | firstname | lastname | birthday |
  158. +-----------+------------+------------+
  159. | albus | dumbledore | 1881-07-01 |
  160. +-----------+------------+------------+
  161. 1 row in set (0,00 sec)
  162.  
  163. mysql>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement