mysql - SQL WORK IMPROVMENT -
player table:
player_id player_name position_id
position table:
position_id position_description
team table:
team_id team_name
game table:
game_id home_team_id guest_team_id score location date
stats table
game_id player_id number of fouls number of rebounds
i have tried following query find various position player can play @ them:
select player.player_name,position.position_name player,position player.fname='john' , position_name='guard,midfield,striker'
i have tried following query list games date , location has example 5 fouls, tried query:
select game.date,location,number of fouls, game,stats game.date=game.id , game.location=game.id , number of fouls > 5 group game.date,game.location
here's start @ least, first couple of points:
i'd avoid column names spaces. mysql handle them if use backticks, find them more trouble they're worth.
these not extremely difficult queries. if have opportunity, spend hour or doing basic mysql tutorial. mysql site has examples.
when select 2 or more tables want
join
them. tutorials cover this.
ok, here queries...
player , positions can play:
select player.player_id, player.player_name, position.position_description player inner join position on player.position_id = position.position_id player.fname = 'john' , position_name in ('guard', 'midfield', 'striker')
games more 5 fouls:
select game.date, game.location, sum(stats.`number of fouls`) totalfouls game inner join stats on game.game_id = stats.game_id group game.date, game.location having sum(stats.`number of fouls`) > 5
Comments
Post a Comment