您的位置:首页 > 数据库

SqlZoo.net习题答案:How to do joins.【Table Tennis】

2012-06-02 00:40 507 查看
习题地址:http://sqlzoo.net/3b.htm

表结构:  ttms(games, color, who, country)
      country(id, name)

      ttms.county = county.id

1b.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 country.name = 'Sweden'


1c.Show the years in which 'China' won a 'gold' medal.

select games
from ttms join country
on (ttms.country = country.id)
where country.name = 'China' and ttms.color = 'gold'


表结构:  ttws(games, color, who, country)
      games(yr, city, country)

      ttws.games = games.yr

2a.Show
who
won medals in the 'Barcelona' games.

select who
from ttws join games
on (ttws.games=games.yr)
where city = 'Barcelona'


2b.Show which city 'Jing Chen' won medals. Show the
city
and the medal
color
.

select games.city, color
from ttws join games
on (ttws.games = games.yr)
where ttws.who = 'Jing Chen'


2c.Show
who
won the gold medal and the
city
.

select ttws.who, games.city
from ttws join games
on (ttws.games = games.yr)
where ttws.color = 'gold'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: