由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 这个query怎么写?谢谢
相关主题
HELP: 如何实现 一个简单的QuerySQL combine two columns from two different tables no shared (转载)
sql 请教Table Merge (SQL Server)
求教如何针对这种情况进行优化其实有个问题好久没有明白!
SQL Server Trigger on System Base Table or Catalog Viewanalyze 在oracle里怎么用?
一个single table 的 SQL QUERY问个external table field definition的问题
如何完成这个sql?sql面试题目求指点
我也问一个sql querry的问题MSQuery
sql server 行转列的问题One sql question help!
相关话题的讨论汇总
话题: table话题: query话题: eteam话题: germany话题: game
进入Database版参与讨论
1 (共1页)
m******u
发帖数: 12400
1
show the name of all players who scored a goal against Germany?
table 1: game: columns (id, mdate, stadium, team1, team2)
table 2: goal: columns(matchid, teamid, player, grime)
table 3: eteam: columns (id, teamname, coach)
其中
game.id = goal.matchid
game.team1 (and team2) = eteam.id = goal.teamid
c*******e
发帖数: 8624
2
select b.player
from game a
join goal b
on a.id = b.matchid
join eteam c
on a.team1 = c.id
and c.teamname = 'Germany'
union
select b.player
from game a
join goal b
on a.id = b.matchid
join eteam c
on a.team2 = c.id
and c.teamname = 'Germany' ;

【在 m******u 的大作中提到】
: show the name of all players who scored a goal against Germany?
: table 1: game: columns (id, mdate, stadium, team1, team2)
: table 2: goal: columns(matchid, teamid, player, grime)
: table 3: eteam: columns (id, teamname, coach)
: 其中
: game.id = goal.matchid
: game.team1 (and team2) = eteam.id = goal.teamid

m******u
发帖数: 12400
3
thanks
m******u
发帖数: 12400
4
the query is not right. too many rows selected.
B*****g
发帖数: 34098
5
把他德进球的队员也算上了
1 试着把union 2部分合并
2 b.teamid和c.id不能一样

【在 m******u 的大作中提到】
: the query is not right. too many rows selected.
m******u
发帖数: 12400
6
one more. Thanks.
Show the stadium and the number of goals scored in each stadium.
m******u
发帖数: 12400
7
thanks, Beijing
m******u
发帖数: 12400
8
if I want to show game id, stadium and the name of the two teams (basically
it is the game table, just in game table the two teams are showed in teamid)
. I need use the game table to join the eteam table twice. Am I correct here
. Thanks.
1 (共1页)
进入Database版参与讨论
相关主题
One sql question help!一个single table 的 SQL QUERY
ask for help with a simple query!!!如何完成这个sql?
How to add a blank column in a Query?我也问一个sql querry的问题
query: in sql server 2005sql server 行转列的问题
HELP: 如何实现 一个简单的QuerySQL combine two columns from two different tables no shared (转载)
sql 请教Table Merge (SQL Server)
求教如何针对这种情况进行优化其实有个问题好久没有明白!
SQL Server Trigger on System Base Table or Catalog Viewanalyze 在oracle里怎么用?
相关话题的讨论汇总
话题: table话题: query话题: eteam话题: germany话题: game