-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram6.txt
38 lines (31 loc) · 1.01 KB
/
Program6.txt
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
5.TO IMPLEMENT CONCEPT OF JOINS
SELECT
first_name,
last_name,
employees.department_id,
departments.department_id,
department_name
FROM
employees
INNER JOIN
departments ON departments.department_id = employees.department_id
WHERE
employees.department_id IN (1 , 2, 3);
first_name last_name department_id department_id department_name
Jenny Whalen 1 1 Administration
Mark Hartstein 2 2 Marketing
Patrick Fay 2 2 Marketing
# LEFT JOIN
SELECT
r.region_name,
c.country_name,
l.street_address,
l.city
FROM
regions r
LEFT JOIN countries c ON c.region_id = r.region_id
LEFT JOIN locations l ON l.country_id = c.country_id
WHERE
c.country_id IN ('US', 'UK', 'CN');
region_name country_name street_address city
Europe United Kingdom 8204 Arthur St London