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:

  1. i'd avoid column names spaces. mysql handle them if use backticks, find them more trouble they're worth.

  2. these not extremely difficult queries. if have opportunity, spend hour or doing basic mysql tutorial. mysql site has examples.

  3. 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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -