Skip to content

Instantly share code, notes, and snippets.

@dragonslayer77
Created May 20, 2019 09:02
Show Gist options
  • Save dragonslayer77/83549e49a2c712595e9d6d5ab782afd2 to your computer and use it in GitHub Desktop.
Save dragonslayer77/83549e49a2c712595e9d6d5ab782afd2 to your computer and use it in GitHub Desktop.
1.) “Durmstrang Institute” is actually in Sweden (Sweden), so modify its country.
mysql> UPDATE school SET country='Sweden' WHERE name='Durmstrang Institute';
Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM school
-> SELECT * FROM school;
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 'SELECT * FROM school' at line 2
mysql> SELECT * FROM school;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Beauxbatons Academy of Magic | 550 | France |
| 2 | Castelobruxo | 380 | Brazil |
| 3 | Durmstrang Institute | 570 | Sweden |
| 4 | Hogwarts School of Witchcraft and Wizardry | 450 | United Kingdom |
| 5 | Ilvermorny School of Witchcraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
| 7 | Mahoutokoro School of Magic | 800 | Japan |
| 8 | Uagadou School of Magic | 350 | Uganda |
+----+----------------------------------------------+----------+----------------+
2.)“Mahoutokoro School of Magic” should have its pupil capacity reduced to 700.
mysql> UPDATE school SET capacity=700 WHERE name='Mahoutokoro School of Magic';
Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM school;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Beauxbatons Academy of Magic | 550 | France |
| 2 | Castelobruxo | 380 | Brazil |
| 3 | Durmstrang Institute | 570 | Sweden |
| 4 | Hogwarts School of Witchcraft and Wizardry | 450 | United Kingdom |
| 5 | Ilvermorny School of Witchcraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
| 7 | Mahoutokoro School of Magic | 700 | Japan |
| 8 | Uagadou School of Magic | 350 | Uganda |
+----+----------------------------------------------+----------+----------------+
3.)Delete all the schools containing the word “Magic” (there are 3) in their titles in a single request. The LIKE keyword may be of help to you.
mysql> DELETE FROM school WHERE name LIKE '%Magic%';
Query OK, 3 rows affected (0.04 sec)
mysql> SELECT * FROM school;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 2 | Castelobruxo | 380 | Brazil |
| 3 | Durmstrang Institute | 570 | Sweden |
| 4 | Hogwarts School of Witchcraft and Wizardry | 450 | United Kingdom |
| 5 | Ilvermorny School of Witchcraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
+----+----------------------------------------------+----------+----------------+
5 rows in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment