标签:player section 修改 oev col mario roman public mat
id(編號) | mdate(日期) | stadium(場館) | team1(隊伍1) | team2(隊伍2) |
---|---|---|---|---|
1001 | 8 June 2012 | National Stadium, Warsaw | POL | GRE |
1002 | 8 June 2012 | Stadion Miejski (Wroclaw) | RUS | CZE |
1003 | 12 June 2012 | Stadion Miejski (Wroclaw) | GRE | CZE |
1004 | 12 June 2012 | National Stadium, Warsaw | POL | RUS |
... |
matchid(賽事編號) | teamid(隊伍編號) | player(入球球員) | gtime(入球時間) | |
---|---|---|---|---|
1001 | POL | Robert Lewandowski | 17 | |
1001 | GRE | Dimitris Salpingidis | 51 | |
1002 | RUS | Alan Dzagoev | 15 | |
1001 | RUS | Roman Pavlyuchenko | 82 | |
... |
id(編號) | teamname(隊名) | coach(教練) | ||
---|---|---|---|---|
POL | Poland | Franciszek Smuda | ||
RUS | Russia | Dick Advocaat | ||
CZE | Czech Republic | Michal Bilek | ||
GRE | Greece | Fernando Santos | ||
... |
teamid = ‘GER‘
SELECT matchid,player FROM goal
WHERE teamid = ‘GER‘
2.由以上查詢,你可見Lars Bender‘s 於賽事 1012入球。.現在我們想知道此賽事的對賽隊伍是哪一隊。
留意在 goal
表格中的欄位 matchid
,是對應表格game
的欄位id
。我們可以在表格 game中找出賽事1012的資料。
只顯示賽事1012的 id, stadium, team1, team2
select id,stadium,team1,team2 from game
where id=‘1012‘
3.以下SQL列出每個入球的球員(來自goal表格)和場館名(來自game表格)
修改它來顯示每一個德國入球的球員名,隊伍名,場館和日期。
SELECT player,teamid,stadium,mdate
FROM game JOIN goal ON (id=matchid)
WHERE teamid=‘GER‘;
4.列出球員名字叫Mario (player LIKE ‘Mario%‘
)有入球的 隊伍1 team1, 隊伍2 team2 和 球員名 player
select team1,team2,player from game join goal on(id=matchid)
where player LIKE ‘Mario%‘
5.列出每場球賽中首10分鐘gtime<=10
有入球的球員 player
, 隊伍teamid
, 教練coach
, 入球時間gtime
select player,teamid,coach,gtime
from goal join eteam on teamid=id
where gtime<10
6.列出‘Fernando Santos‘作為隊伍1 team1 的教練的賽事日期,和隊伍名。
SELECT mdate,teamname
FROM game JOIN eteam ON game.team1=eteam.id
WHERE eteam.coach=‘Fernando Santos‘
7.列出場館 ‘National Stadium, Warsaw‘的入球球員。
select player from goal join game on game.id=goal.matchid
where game.stadium=‘National Stadium, Warsaw‘
SQL练习-SQLZOO SQLZOO:The JOIN operation
标签:player section 修改 oev col mario roman public mat
原文地址:https://www.cnblogs.com/cat30/p/12971479.html