Skip to content

Instantly share code, notes, and snippets.

@evadav
Created May 22, 2019 10:36
Show Gist options
  • Save evadav/79eb04f9781b895f6d2c71acf2f6ab11 to your computer and use it in GitHub Desktop.
Save evadav/79eb04f9781b895f6d2c71acf2f6ab11 to your computer and use it in GitHub Desktop.
Retrieving wizards
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.5.24-log MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> USE wild_db_quest;
Database changed
mysql> DESCRIBE wild_db_quest;
ERROR 1146 (42S02): Table 'wild_db_quest.wild_db_quest' doesn't exist
mysql> DESCRIBE wizard;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| firstname | varchar(100) | NO | | NULL | |
| lastname | varchar(100) | NO | | NULL | |
| birthday | date | NO | | NULL | |
| birth_place | varchar(255) | YES | | NULL | |
| biography | text | YES | | NULL | |
| is_muggle | tinyint(1) | NO | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
7 rows in set (0.01 sec)
mysql> SELECT birthday
-> FROM wizard
-> WHERE
-> birthday BETWEEN '1975-01-01' AND '1986-01-01';
+------------+
| birthday |
+------------+
| 1980-07-31 |
| 1979-09-19 |
| 1980-03-01 |
| 1981-08-11 |
| 1978-04-01 |
| 1978-04-01 |
| 1980-06-05 |
| 1980-06-23 |
| 1980-06-23 |
+------------+
9 rows in set (0.06 sec)
mysql> SELECT firstname
-> FROM wizard
-> WHERE
-> firstname LIKE 'H%';
+-----------+
| firstname |
+-----------+
| harry |
| hermione |
+-----------+
2 rows in set (0.00 sec)
mysql> SELECT lastname AND firstname FROM wizard WHERE lastname = 'Potter' ORDE
R BY firstname DESC;
+------------------------+
| lastname AND firstname |
+------------------------+
| 0 |
| 0 |
+------------------------+
2 rows in set, 2 warnings (0.04 sec)
mysql> SELECT firstname,lastname
-> FROM wizard
-> WHERE
-> firstname = 'potter'
-> ORDER BY firstname DESC;
Empty set (0.00 sec)
mysql> SHOW wizards;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'wizar
ds' at line 1
mysql> SHOW wizard;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'wizar
d' at line 1
mysql> SELECT * FROM wizard;
+----+-----------+------------+------------+-------------+----------------------
---------------------------------------+-----------+
| 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 Potte
r | 0 |
| 3 | lily | potter | 1960-01-30 | | mother of Harry Potte
r | 0 |
| 4 | ron | weasley | 1980-03-01 | | Best friend of Harry
| 0 |
| 5 | ginny | weasley | 1981-08-11 | | Sister of Ron and gir
lfriend of Harry | 0 |
| 6 | fred | weasley | 1978-04-01 | |
| 0 |
| 7 | george | weasley | 1978-04-01 | |
| 0 |
| 8 | arthur | weasley | 1950-02-06 | |
| 0 |
| 9 | molly | weasley | 1949-01-01 | |
| 0 |
| 10 | drago | malefoy | 1980-06-05 | |
| 0 |
| 11 | albus | dumbledore | 1881-07-01 | |
| 0 |
| 12 | severus | rogue | 1960-01-09 | |
| 0 |
| 13 | tom | jédusor | 1926-12-31 | | Celui-Dont-On-Ne-Doit
-Pas-Prononcer-Le-Nom alias Voldermort | 0 |
| 14 | dudley | dursley | 1980-06-23 | | Cousin d'Harry
| 1 |
| 15 | dudley | dursley | 1980-06-23 | | Cousin d'Harry
| 1 |
+----+-----------+------------+------------+-------------+----------------------
---------------------------------------+-----------+
15 rows in set (0.00 sec)
mysql> SELECT firstname, lastname
-> FROM wizard
-> WHERE lastname='potter'
-> ORDER BY firstname;
+-----------+----------+
| firstname | lastname |
+-----------+----------+
| harry | potter |
| lily | potter |
+-----------+----------+
2 rows in set (0.00 sec)
mysql> SELECT firstname,lastname,birthday
-> FROM wizard
-> ORDER BY birthday ASC LIMIT 0,1;
+-----------+------------+------------+
| firstname | lastname | birthday |
+-----------+------------+------------+
| albus | dumbledore | 1881-07-01 |
+-----------+------------+------------+
1 row in set (0.04 sec)
mysql>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment