-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJoin data
More file actions
71 lines (50 loc) · 2.33 KB
/
Join data
File metadata and controls
71 lines (50 loc) · 2.33 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
59
60
61
62
63
64
65
66
67
68
69
70
xxx==============================================================================================================xxx
[Notes - For joining two table with common row, here it's EmployeeID]
SELECT * FROM EmployeeDemographics
INNER JOIN EmployeeSalary
ON EmployeeDemographics.EmployeeID = EmployeeSalary.EmployeeID
;
xxx==============================================================================================================xxx
[Notes - For joining two table with common row, here it's EmployeeID]
SELECT * FROM EmployeeDemographics AS DEM
INNER JOIN EmployeeSalary AS EMS
ON DEM.EmployeeID = EMS.EmployeeID
;
xxx==============================================================================================================xxx
[Notes - For joining two table with common row, here it's EmployeeID]
SELECT DEM.Age, Gender, Salary
FROM EmployeeDemographics AS DEM
INNER JOIN EmployeeSalary AS EMS
ON DEM.EmployeeID = EMS.EmployeeID
;
xxx==============================================================================================================xxx
[Notes - RIGHT JOIN is taking everything from right table and matching it with the left table]
SELECT *
FROM EmployeeDemographics AS DEM
RIGHT JOIN EmployeeSalary AS EMS
ON DEM.EmployeeID = EMS.EmployeeID
;
xxx==============================================================================================================xxx
[Notes - LEFT JOIN is taking everything from left table and matching it with the left table]
SELECT *
FROM EmployeeDemographics AS DEM
LEFT JOIN EmployeeSalary AS EMS
ON DEM.EmployeeID = EMS.EmployeeID
;
xxx==============================================================================================================xxx
[Notes - LEFT JOIN is taking everything from left table and matching it with the left table]
SELECT *
FROM EmployeeSalary AS emp1
JOIN EmployeeSalary AS emp2
ON emp1.EmployeeID + 1 = emp2.EmployeeID
;
xxx==============================================================================================================xxx
[Notes - LEFT JOIN is taking everything from left table and matching it with the left table]
SELECT emp1.EmployeeID as emp_santa,
emp1.FirstName as FirstName_santa,
emp2.EmployeeID as emp_santa,
emp2.FirstName as FirstName_santa
FROM EmployeeDemographics AS emp1
JOIN EmployeeDemographics AS emp2
ON emp1.EmployeeID + 1 = emp2.EmployeeID
;