您好,欢迎来到华佗小知识。
搜索
您的当前位置:首页SqlZoo.net习题答案:How to do joins.【Table Tennis】

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

来源:华佗小知识

 

表结构:  ttms(gamescolor, 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(gamescolor, 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 medalcolor.

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'

 

 

 

转载于:https://www.cnblogs.com/Leo-Forest/archive/2012/06/02/2531468.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- huatuo0.cn 版权所有 湘ICP备2023017654号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务