Skip to content

Instantly share code, notes, and snippets.

@51enra
Created December 2, 2019 10:34
Show Gist options
  • Save 51enra/6b798139d2e7c27f349fcb1fa8f45ff1 to your computer and use it in GitHub Desktop.
Save 51enra/6b798139d2e7c27f349fcb1fa8f45ff1 to your computer and use it in GitHub Desktop.

Revisions

  1. 51enra created this gist Dec 2, 2019.
    41 changes: 41 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    SELECT * FROM wizard WHERE birthday BETWEEN '1975-01-01' AND '1985-12-31';

    +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
    | 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 Potter | 0 |
    | 4 | ron | weasley | 1980-03-01 | | Best friend of Harry | 0 |
    | 5 | ginny | weasley | 1981-08-11 | | Sister of Ron and girlfriend of Harry | 0 |
    | 6 | fred | weasley | 1978-04-01 | | | 0 |
    | 7 | george | weasley | 1978-04-01 | | | 0 |
    | 10 | drago | malefoy | 1980-06-05 | | | 0 |
    | 14 | dudley | dursley | 1980-06-23 | | Cousin d'Harry | 1 |
    +----+-----------+----------+------------+-------------+---------------------------------------+-----------+

    SELECT * FROM wizard WHERE firstname LIKE 'H%';

    +----+-----------+----------+------------+-------------+------------------------+-----------+
    | 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 Potter | 0 |
    +----+-----------+----------+------------+-------------+------------------------+-----------+

    SELECT firstname,lastname FROM wizard WHERE lastname='Potter' ORDER BY firstname;

    +-----------+----------+
    | firstname | lastname |
    +-----------+----------+
    | harry | potter |
    | lily | potter |
    +-----------+----------+

    SELECT firstname,lastname,birthday FROM wizard ORDER BY birthday ASC LIMIT 1;

    +-----------+------------+------------+
    | firstname | lastname | birthday |
    +-----------+------------+------------+
    | albus | dumbledore | 1881-07-01 |
    +-----------+------------+------------+