Skip to content

Instantly share code, notes, and snippets.

@juliaheller
Created March 10, 2020 12:54
Show Gist options
  • Select an option

  • Save juliaheller/c8ff095e793c49b37793a01090c11795 to your computer and use it in GitHub Desktop.

Select an option

Save juliaheller/c8ff095e793c49b37793a01090c11795 to your computer and use it in GitHub Desktop.
mysql> insert into school(name, country, capacity) values (Beauxbatons Academy of Magic, France, 550), (Castelobruxo, Brasil, 380), (Durmstrang Institute, Norway, 570), (Hogwarts School of Witchcraft and Wizardry, United Kingdom, 450), (Ilvermorny School of Witchcraft and Wizardry, USA, 300), (Koldovstoretz, Russia, 125), (Mahoutokoro School of Magic, Japan, 800), (Uagadou School of Magic, Uganda, 350);
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 'Academy of Magic, France, 550), (Castelobruxo, Brasil, 380), (Durmstrang Institu' at line 1
mysql> insert into school(name, country, capacity) values ('Beauxbatons Academy of Magic', 'France', 550), ('Castelobruxo', 'Brasil', 380), ('Durmstrang Institute', 'Norway', 570), ('Hogwarts School of Witchcraft and Wizardry', 'United Kingdom', 450), ('Ilvermorny School of Witchcraft and Wizardry', 'USA', 300), ('Koldovstoretz', 'Russia', 125), ('Mahoutokoro School of Magic', 'Japan', 800), ('Uagadou School of Magic', 'Uganda', 350);
Query OK, 8 rows affected (0,01 sec)
Records: 8 Duplicates: 0 Warnings: 0
mysql> select * from school; +----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Beauxbatons Academy of Magic | 550 | France |
| 2 | Castelobruxo | 380 | Brasil |
| 3 | Durmstrang Institute | 570 | Norway |
| 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 |
+----+----------------------------------------------+----------+----------------+
8 rows in set (0,01 sec)
mysql> update school set country=Sweden where id=3;
ERROR 1054 (42S22): Unknown column 'Sweden' in 'field list'
mysql> update school set country='Sweden' where id=3;
Query OK, 1 row affected (0,00 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 | Brasil |
| 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 |
+----+----------------------------------------------+----------+----------------+
8 rows in set (0,00 sec)
mysql> update school set capacity=700 where id=7;
Query OK, 1 row affected (0,00 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 | Brasil |
| 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 |
+----+----------------------------------------------+----------+----------------+
8 rows in set (0,00 sec)
mysql> delete from school where name like 'Magic%';
Query OK, 0 rows affected (0,00 sec)
mysql> select * from school;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Beauxbatons Academy of Magic | 550 | France |
| 2 | Castelobruxo | 380 | Brasil |
| 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 |
+----+----------------------------------------------+----------+----------------+
8 rows in set (0,00 sec)
mysql> delete from school where name like '%Magic%';
Query OK, 3 rows affected (0,01 sec)
mysql> select * from school;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 2 | Castelobruxo | 380 | Brasil |
| 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)
mysql>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment