Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 | YES | | NULL | |
- | birth_place | varchar(255) | YES | | NULL | |
- | biography | text | YES | | NULL | |
- | is_muggle | tinyint(1) | YES | | NULL | |
- +-------------+--------------+------+-----+---------+----------------+
- 7 rows in set (0,01 sec)
- 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 Potter | 0 |
- | 3 | lily | potter | 1960-01-30 | | mother 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 |
- | 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 |
- +----+-----------+------------+------------+-------------+-------------------------------------------------------------+-----------+
- 14 rows in set (0,00 sec)
- mysql> select firstname, lastname from wizard;
- +-----------+------------+
- | firstname | lastname |
- +-----------+------------+
- | harry | potter |
- | hermione | granger |
- | lily | potter |
- | ron | weasley |
- | ginny | weasley |
- | fred | weasley |
- | george | weasley |
- | arthur | weasley |
- | molly | weasley |
- | drago | malefoy |
- | albus | dumbledore |
- | severus | rogue |
- | tom | jédusor |
- | dudley | dursley |
- +-----------+------------+
- 14 rows in set (0,01 sec)
- mysql> select * from wizard where birthday between '1975' and '1985' ;
- Empty set, 2 warnings (0,01 sec)
- mysql> select * from wizard where birthday between '1975-01-01' and '1985-01-01' ;
- +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
- | 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 |
- +----+-----------+----------+------------+-------------+---------------------------------------+-----------+
- 8 rows in set (0,01 sec)
- mysql> select firstname from wizard where fistname like 'H%'
- -> ;
- ERROR 1054 (42S22): Unknown column 'fistname' in 'where clause'
- mysql> select firstname from wizard where fistname like 'H%';
- ERROR 1054 (42S22): Unknown column 'fistname' in 'where clause'
- mysql> select firstname from wizard where fistname like 'H';
- ERROR 1054 (42S22): Unknown column 'fistname' in 'where clause'
- mysql> select * from wizard where firstname like 'H';
- Empty set (0,01 sec)
- mysql> 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 |
- +----+-----------+----------+------------+-------------+------------------------+-----------+
- 2 rows in set (0,00 sec)
- mysql> select firstname, lastname from wizard where lastname='Potter';
- +-----------+----------+
- | firstname | lastname |
- +-----------+----------+
- | harry | potter |
- | lily | potter |
- +-----------+----------+
- 2 rows in set (0,01 sec)
- mysql> select firstname, lastname from wizard where lastname='Potter' order by firstname ;
- +-----------+----------+
- | firstname | lastname |
- +-----------+----------+
- | harry | potter |
- | lily | potter |
- +-----------+----------+
- 2 rows in set (0,01 sec)
- mysql> select * from wizard where lastname='Potter' order by firstname ;
- +----+-----------+----------+------------+-------------+------------------------+-----------+
- | id | firstname | lastname | birthday | birth_place | biography | is_muggle |
- +----+-----------+----------+------------+-------------+------------------------+-----------+
- | 1 | harry | potter | 1980-07-31 | london | | 0 |
- | 3 | lily | potter | 1960-01-30 | | mother of Harry Potter | 0 |
- +----+-----------+----------+------------+-------------+------------------------+-----------+
- 2 rows in set (0,00 sec)
- mysql> select firstname, lastname, birthday from wizard where birthday='birthday desc';
- ERROR 1525 (HY000): Incorrect DATE value: 'birthday desc'
- mysql> select firstname, lastname, birthday from wizard order by birthday;
- +-----------+------------+------------+
- | firstname | lastname | birthday |
- +-----------+------------+------------+
- | albus | dumbledore | 1881-07-01 |
- | tom | jédusor | 1926-12-31 |
- | molly | weasley | 1949-01-01 |
- | arthur | weasley | 1950-02-06 |
- | severus | rogue | 1960-01-09 |
- | lily | potter | 1960-01-30 |
- | fred | weasley | 1978-04-01 |
- | george | weasley | 1978-04-01 |
- | hermione | granger | 1979-09-19 |
- | ron | weasley | 1980-03-01 |
- | drago | malefoy | 1980-06-05 |
- | dudley | dursley | 1980-06-23 |
- | harry | potter | 1980-07-31 |
- | ginny | weasley | 1981-08-11 |
- +-----------+------------+------------+
- 14 rows in set (0,01 sec)
- mysql> select firstname, lastname, birthday from wizard order by birthday limit 1,1;
- +-----------+----------+------------+
- | firstname | lastname | birthday |
- +-----------+----------+------------+
- | tom | jédusor | 1926-12-31 |
- +-----------+----------+------------+
- 1 row in set (0,00 sec)
- mysql> select firstname, lastname, birthday from wizard order by birthday limit 1,0;
- Empty set (0,00 sec)
- mysql> select firstname, lastname, birthday from wizard order by birthday limit 0,1;
- +-----------+------------+------------+
- | firstname | lastname | birthday |
- +-----------+------------+------------+
- | albus | dumbledore | 1881-07-01 |
- +-----------+------------+------------+
- 1 row in set (0,00 sec)
- mysql>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement