-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQL_Final_Project.sql
More file actions
61 lines (50 loc) · 1.36 KB
/
Copy pathSQL_Final_Project.sql
File metadata and controls
61 lines (50 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Drop Table If exists Students;
Drop Table If exists Interests;
--Create Table
CREATE TABLE Students (
StudentID INT,
HobbyID INT,
StudentName VARCHAR(50)
);
-- Insert Values
INSERT INTO Students VALUES
(1, 1,'Central Limit Theorem Group'),-- inserts names here
(2, 2,'Linear Regression Group'),
(3, 3,'Hash tables Group'),
(4, 4,'DB Keys Group'),
(5, 4,'Hypothesis Testing Group'),
(6, 5,'Linear Regression Group'),
(7, 0,'Relational Joins Group')
;
CREATE TABLE Interests (
HobbyID INT,
Hobby VARCHAR(50)
);
INSERT INTO Interests VALUES
(1, 'Music'),
(2, 'Sports'),
(3, 'Reading'),
(4, 'Eating'),
(5, 'Sleeping'),
(6, 'Art'),
(7, 'Teaching');
Select Interests.Hobby from Interests;
-- Inner join, is like forming groups based on hobby
SELECT Students.StudentName, Interests.Hobby
FROM Students
INNER JOIN Interests ON Students.HobbyID = Interests.HobbyID;
-- Left join
--The Inclusive Study Session
SELECT Students.StudentName, Interests.Hobby
FROM Students
LEFT JOIN Interests ON Students.HobbyID = Interests.HobbyID;
--Right join
-- An Exclusive Club of Hobby Enthusiasts
--
SELECT Students.StudentName, Interests.Hobby
FROM Students
RIGHT JOIN Interests ON Students.HobbyID = Interests.HobbyID;
--Full Join the - The Ultimate Study Party
SELECT Students.StudentName, Interests.Hobby
FROM Students
FULL JOIN Interests ON Students.HobbyID = Interests.HobbyID;