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

Labs done #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/answers/exercise10.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students WHERE city = 'Philadelphia' OR 'Trenton';
25 changes: 25 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise11.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
SELECT * FROM Students ORDER BY city;

INSERT INTO Students (
StudentName,
Address,
City,
PostalCode,
Country)
VALUES (
'John Song',
'57 bbbbb St',
'Philadelphia', 'GG13BB',
'United States');

INSERT INTO Students (
StudentName,
Address,
City,
PostalCode,
Country)
VALUES (
'JAR JAR',
'57 BINKS St',
'Trenton', 'GG234B',
'New Jersey');
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/answers/exercise12.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students ORDER BY city DESC;
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/answers/exercise13.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students ORDER BY country, city;
6 changes: 6 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise16.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
UPDATE Students
SET City = 'EDinburgh';

SET SQL_SAFE_UPDATES = 0;


4 changes: 4 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise17.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
UPDATE Students
SET City = 'EDinburgh' WHERE Country = 'Scotland';

SELECT * FROM STudents;
4 changes: 4 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise18.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
UPDATE Students
SET City = 'EDinburgh' AND Country = 'Scotland'
WHERE ID = 35;

3 changes: 3 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise20.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DELETE FROM Students;

SELECT * FROM STudents;
2 changes: 2 additions & 0 deletions exercise1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE DATABASE myNewDB;
SHOW DATABASES;
1 change: 1 addition & 0 deletions exercise10.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students WHERE city = 'Philadelphia' OR 'Trenton';
25 changes: 25 additions & 0 deletions exercise11.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
SELECT * FROM Students ORDER BY city;

INSERT INTO Students (
StudentName,
Address,
City,
PostalCode,
Country)
VALUES (
'John Song',
'57 bbbbb St',
'Philadelphia', 'GG13BB',
'United States');

INSERT INTO Students (
StudentName,
Address,
City,
PostalCode,
Country)
VALUES (
'JAR JAR',
'57 BINKS St',
'Trenton', 'GG234B',
'New Jersey');
1 change: 1 addition & 0 deletions exercise12.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students ORDER BY city DESC;
1 change: 1 addition & 0 deletions exercise13.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students ORDER BY country, city;
2 changes: 2 additions & 0 deletions exercise2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DROP DATABASE myNewDB;
SHOW DATABASES;
6 changes: 6 additions & 0 deletions exercise3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE Users (
userid INT,
FirstName VARCHAR(255),
LastName VARCHAR(255),
Adress VARCHAR(255),
City VARCHAR(255));
2 changes: 2 additions & 0 deletions exercise4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Drop TABLE Users;
describe Users;
5 changes: 5 additions & 0 deletions exercise5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
truncate TABLE Users;
describe Users;



2 changes: 2 additions & 0 deletions exercise6.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE Users ADD Birthday DATE;
DESCRIBE Users;
1 change: 1 addition & 0 deletions exercise7.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE Users DROP Birthday;
22 changes: 22 additions & 0 deletions exercise8.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

INSERT INTO Students (
StudentName,
Address,
City,
PostalCode,
Country)
VALUES (
'Jane Doe',
'57 Union St',
'Glasgow', 'G13RB',
'Scotland');

CREATE TABLE Students(
StudentName VARCHAR(255),
Address VARCHAR (255),
City VARCHAR (255),
PostalCode VARCHAR(20),
Country VARCHAR(100));

SELECT * FROM Students;
Describe Students;
1 change: 1 addition & 0 deletions exercise9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students WHERE NOT 'Philadelphia';