cyberhafid
5/17/2019 - 8:46 AM

quete select

quete select


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 * FROM wizard where lastname='potter' ORDER BY firstname DESC;
+----+-----------+----------+------------+-------------+------------------------+-----------+
| id | firstname | lastname | birthday   | birth_place | biography              | is_muggle |
+----+-----------+----------+------------+-------------+------------------------+-----------+
|  3 | lily      | potter   | 1960-01-30 |             | mother of Harry Potter |         0 |
|  1 | harry     | potter   | 1980-07-31 | london      |                        |         0 |
+----+-----------+----------+------------+-------------+------------------------+-----------+
2 rows in set (0.00 sec)

mysql> SELECT firstname, lastname FROM wizard ORDER BY birthday DESC  LIMIT 0,1; 
+-----------+----------+
| firstname | lastname |
+-----------+----------+
| ginny     | weasley  |
+-----------+----------+
1 row in set (0.00 sec)

mysql> SELECT * FROM wizard where is_muggle ='0' and 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 |
+----+-----------+----------+------------+-------------+---------------------------------------+-----------+
7 rows in set (0.00 sec)

mysql>