Skip to content

Instantly share code, notes, and snippets.

@alyson-b69
Created September 7, 2020 09:56
Show Gist options
  • Save alyson-b69/ae125115beab8bf2e1f118728279f779 to your computer and use it in GitHub Desktop.
Save alyson-b69/ae125115beab8bf2e1f118728279f779 to your computer and use it in GitHub Desktop.
SELECT wild quest
mysql> SELECT * FROM wizard WHERE birthday BETWEEN '1975-01-01' AND '1985-01-01';
+----+-----------+----------+------------+-------------+---------------------------------------+-----------+
| id | firstname | lastname | birthday | birth_place | biography | is_muggle |
+----+-----------+----------+------------+-------------+---------------------------------------+-----------+
| 14 | harry | potter | 1980-07-31 | london | | 0 |
| 15 | hermione | granger | 1979-09-19 | | Friend of Harry Potter | 0 |
| 17 | ron | weasley | 1980-03-01 | | Best friend of Harry | 0 |
| 18 | ginny | weasley | 1981-08-11 | | Sister of Ron and girlfriend of Harry | 0 |
| 19 | fred | weasley | 1978-04-01 | | | 0 |
| 20 | george | weasley | 1978-04-01 | | | 0 |
| 23 | drago | malefoy | 1980-06-05 | | | 0 |
| 27 | dudley | dursley | 1980-06-23 | | Cousin d'Harry | 1 |
+----+-----------+----------+------------+-------------+---------------------------------------+-----------+
8 rows in set (0,00 sec)
mysql> SELECT firstname FROM wizard WHERE firstname LIKE 'H%';
+-----------+
| firstname |
+-----------+
| harry |
| hermione |
+-----------+
2 rows in set (0,00 sec)
mysql> SELECT firstname, lastname FROM wizard WHERE lastname='potter' ORDER BY firstname ASC;
+-----------+----------+
| 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 1;
+-----------+------------+------------+
| firstname | lastname | birthday |
+-----------+------------+------------+
| albus | dumbledore | 1881-07-01 |
+-----------+------------+------------+
1 row in set (0,00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment