BDD CHALLENGE 3 update/delete
INSERT INTO schools (name, country, capacity) VALUES
-> ('Castelobruxo', 'Brazil', 380),
-> ('Ilvermorny School of Witchkraft and Wizardry', 'USA', 300),
-> ('Koldovstoretz', 'Russia', 125),
-> ('Mahoutokoro', 'Japan', 800),
-> ('Uagadou School of Magic', 'Uganda', 350);
SELECT * FROM schools;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Hogwarts | 400 | United-Kingdom |
| 2 | Beauxbatons | 550 | France |
| 3 | Durmstrang Institute | 579 | Norway |
| 4 | Castelobruxo | 380 | Brazil |
| 5 | Ilvermorny School of Witchkraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
| 7 | Mahoutokoro | 800 | Japan |
| 8 | Uagadou School of Magic | 350 | Uganda |
+----+----------------------------------------------+----------+----------------+
8 rows in set (0,00 sec)
mysql> UPDATE schools
-> SET country = 'Sweden'
-> WHERE id = 3;
SELECT * FROM schools;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Hogwarts | 400 | United-Kingdom |
| 2 | Beauxbatons | 550 | France |
| 3 | Durmstrang Institute | 579 | Sweden |
| 4 | Castelobruxo | 380 | Brazil |
| 5 | Ilvermorny School of Witchkraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
| 7 | Mahoutokoro | 800 | Japan |
| 8 | Uagadou School of Magic | 350 | Uganda |
+----+----------------------------------------------+----------+----------------+
8 rows in set (0,00 sec)
UPDATE schools
-> SET capacity = 700
-> WHERE id = 7;
Query OK, 1 row affected (0,00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM schools;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Hogwarts | 400 | United-Kingdom |
| 2 | Beauxbatons | 550 | France |
| 3 | Durmstrang Institute | 579 | Sweden |
| 4 | Castelobruxo | 380 | Brazil |
| 5 | Ilvermorny School of Witchkraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
| 7 | Mahoutokoro | 700 | Japan |
| 8 | Uagadou School of Magic | 350 | Uganda |
+----+----------------------------------------------+----------+----------------+
8 rows in set (0,00 sec)
DELETE FROM schools
-> WHERE name LIKE '% Magic';
Query OK, 3 rows affected (0,26 sec)
mysql> SELECT * FROM schools;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Hogwarts | 400 | United-Kingdom |
| 3 | Durmstrang Institute | 579 | Sweden |
| 4 | Castelobruxo | 380 | Brazil |
| 5 | Ilvermorny School of Witchkraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
+----+----------------------------------------------+----------+----------------+
5 rows in set (0,00 sec)