-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOld_JOIN_Tutorial
62 lines (42 loc) · 1.58 KB
/
Old_JOIN_Tutorial
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
--ttms(games,color,who,country)
--country(id,name)
--1. Show the athelete (who) and the country name for medal winners in 2000.
SELECT who, name
FROM ttms JOIN country ON ttms.country=country.id
WHERE games=2000;
--2. Show the who and the color of the medal for the medal winners from 'Sweden'.
SELECT who, color
FROM ttms JOIN country ON ttms.country=country.id
WHERE name='Sweden';
--3. Show the years in which 'China' won a 'gold' medal.
SELECT games
FROM ttms JOIN country ON ttms.country=country.id
WHERE ttms.color='gold' AND country.name='China';
--ttws(games,color,who,country)
--games(yr,city,country)
--4. Show who won medals in the 'Barcelona' games.
SELECT ttws.who
FROM ttws JOIN games ON ttws.games=games.yr
WHERE games.city='Barcelona';
--5. Show which city 'Jing Chen' won medals. Show the city and the medal color.
SELECT city, color
FROM games JOIN ttws ON games.yr=ttws.games
WHERE ttws.who='Jing Chen';
--6. Show who won the gold medal and the city.
SELECT who, city
FROM games JOIN ttws ON games.yr=ttws.games
WHERE ttws.color='gold';
--ttmd(games,color,team,country)
--team(id,,name)
--7. Show the games and color of the medal won by the team that includes 'Yan Sen'.
SELECT games, color
FROM ttmd JOIN team ON ttmd.team=team.id
WHERE team.name='Yan Sen';
--8. Show the 'gold' medal winners in 2004.
SELECT team.name
FROM ttmd JOIN team ON ttmd.team=team.id
WHERE ttmd.games=2004 AND ttmd.color='gold';
--9. Show the name of each medal winner country 'FRA'.
SELECT team.name
FROM ttmd JOIN team ON ttmd.team=team.id
WHERE ttmd.country='FRA';