Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Done #14

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/SQL.BuildAndDestroy.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions answers/exercise1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mysql> CREATE DATABASE myNewDB
1 change: 1 addition & 0 deletions answers/exercise10.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mysql> SELECT * FROM Students WHERE City='Philadelphia' OR City='Trenton';
9 changes: 9 additions & 0 deletions answers/exercise11.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mysql> SELECT * FROM Students ORDER BY City ASC;
+-------------+-------------+--------------+----------+------------+
| StudentName | Address | City | Country | PostalCode |
+-------------+-------------+--------------+----------+------------+
| Jane Doe | 57 Union St | Glasgow | Scotland | G13RB |
| John Doe | 58 Union St | Philadelphia | USA | 19805 |
| Joe Doe | 58 Union St | Trenton | USA | 19805 |
| John John | 58 Union St | Wilmington | USA | 19805 |
+-------------+-------------+--------------+----------+------------+
9 changes: 9 additions & 0 deletions answers/exercise12.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mysql> SELECT * FROM Students ORDER BY City DESC;
+-------------+-------------+--------------+----------+------------+
| StudentName | Address | City | Country | PostalCode |
+-------------+-------------+--------------+----------+------------+
| John John | 58 Union St | Wilmington | USA | 19805 |
| Joe Doe | 58 Union St | Trenton | USA | 19805 |
| John Doe | 58 Union St | Philadelphia | USA | 19805 |
| Jane Doe | 57 Union St | Glasgow | Scotland | G13RB |
+-------------+-------------+--------------+----------+------------+
11 changes: 11 additions & 0 deletions answers/exercise13.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mysql> SELECT * FROM Students ORDER BY Country ASC, City ASC;
+-------------+-------------+--------------+----------+------------+
| StudentName | Address | City | Country | PostalCode |
+-------------+-------------+--------------+----------+------------+
| Jose Jose | 58 Union St | ACityName | Mexico | 19805 |
| Jose Jose | 58 Union St | Wilmington | Mexico | 19805 |
| Jane Doe | 57 Union St | Glasgow | Scotland | G13RB |
| John Doe | 58 Union St | Philadelphia | USA | 19805 |
| Joe Doe | 58 Union St | Trenton | USA | 19805 |
| John John | 58 Union St | Wilmington | USA | 19805 |
+-------------+-------------+--------------+----------+------------+
16 changes: 16 additions & 0 deletions answers/exercise14.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


/*Should I have created the table without
including IS NOT NULL?
That way my query would have said
'WHERE PostalCode IS NULL;'
*/


mysql> SELECT * FROM Students WHERE PostalCode='';
+---------------+-------------+-----------+---------+------------+
| StudentName | Address | City | Country | PostalCode |
+---------------+-------------+-----------+---------+------------+
| Jose Jose | 58 Union St | ACityName | Mexico | |
| Jose LastName | 58 Union St | ACityName | Mexico | |
+---------------+-------------+-----------+---------+------------+
13 changes: 13 additions & 0 deletions answers/exercise15.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mysql> SELECT * FROM Students WHERE PostalCode IS NOT NULL;
+---------------+-------------+--------------+----------+------------+
| StudentName | Address | City | Country | PostalCode |
+---------------+-------------+--------------+----------+------------+
| Jane Doe | 57 Union St | Glasgow | Scotland | G13RB |
| John Doe | 58 Union St | Philadelphia | USA | 19805 |
| Joe Doe | 58 Union St | Trenton | USA | 19805 |
| John John | 58 Union St | Wilmington | USA | 19805 |
| Jose Jose | 58 Union St | Wilmington | Mexico | 19805 |
| Jose Jose | 58 Union St | ACityName | Mexico | 19805 |
| Jose Jose | 58 Union St | ACityName | Mexico | |
| Jose LastName | 58 Union St | ACityName | Mexico | |
+---------------+-------------+--------------+----------+------------+
15 changes: 15 additions & 0 deletions answers/exercise16.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*From The Last Kingdom?*/

mysql> UPDATE Students SET City = 'Edinburgh';
+---------------+-------------+-----------+----------+------------+
| StudentName | Address | City | Country | PostalCode |
+---------------+-------------+-----------+----------+------------+
| Jane Doe | 57 Union St | Edinburgh | Scotland | G13RB |
| John Doe | 58 Union St | Edinburgh | USA | 19805 |
| Joe Doe | 58 Union St | Edinburgh | USA | 19805 |
| John John | 58 Union St | Edinburgh | USA | 19805 |
| Jose Jose | 58 Union St | Edinburgh | Mexico | 19805 |
| Jose Jose | 58 Union St | Edinburgh | Mexico | 19805 |
| Jose Jose | 58 Union St | Edinburgh | Mexico | |
| Jose LastName | 58 Union St | Edinburgh | Mexico | |
+---------------+-------------+-----------+----------+------------+
13 changes: 13 additions & 0 deletions answers/exercise17.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mysql> UPDATE Students SET City = 'Edinburgh' WHERE Country = 'Scotland';
+---------------+-------------+-----------+----------+------------+
| StudentName | Address | City | Country | PostalCode |
+---------------+-------------+-----------+----------+------------+
| Jane Doe | 57 Union St | Edinburgh | Scotland | G13RB |
| John Doe | 58 Union St | CityName | USA | 19805 |
| Joe Doe | 58 Union St | CityName | USA | 19805 |
| John John | 58 Union St | CityName | USA | 19805 |
| Jose Jose | 58 Union St | CityName | Mexico | 19805 |
| Jose Jose | 58 Union St | CityName | Mexico | 19805 |
| Jose Jose | 58 Union St | CityName | Mexico | |
| Jose LastName | 58 Union St | CityName | Mexico | |
+---------------+-------------+-----------+----------+------------+
1 change: 1 addition & 0 deletions answers/exercise18.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UPDATE Students SET City='EdinBurgh', Country='Scotland' Where ID='35';
1 change: 1 addition & 0 deletions answers/exercise19.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM Students WHERE Country = 'Scotland';
1 change: 1 addition & 0 deletions answers/exercise2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mysql> DROP DATABASE myNewDB;
1 change: 1 addition & 0 deletions answers/exercise20.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TRUNCATE TABLE Students;
6 changes: 6 additions & 0 deletions answers/exercise3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mysql> CREATE TABLE Users (
-> UserID INTEGER KEY NOT NULL AUTO_INCREMENT,
-> LastName VARCHAR(255) NOT NULL,
-> FirstName VARCHAR(255) NOT NULL,
-> Address VARCHAR(255) NOT NULL,
-> City VARCHAR(255) NOT NULL);
3 changes: 3 additions & 0 deletions answers/exercise4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DROP TABLE Users;


1 change: 1 addition & 0 deletions answers/exercise5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TRUNCATE TABLE Users;
1 change: 1 addition & 0 deletions answers/exercise6.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mysql> ALTER TABLE Users ADD COLUMN Birthday DATE;
1 change: 1 addition & 0 deletions answers/exercise7.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE Users DROP COLUMN Birthday;
1 change: 1 addition & 0 deletions answers/exercise8.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mysql> INSERT INTO Students (StudentName,Address,City,Country,PostalCode) VALUES ('Jane Doe','57 Union St','Glasgow','Scotland','G13RB');
1 change: 1 addition & 0 deletions answers/exercise9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mysql> SELECT * FROM Students WHERE City<>'Philadelphia';