Results 1 to 3 of 3

Thread: Creating a View

  1. #1
    Join Date
    Aug 2009
    Posts
    2

    Unanswered: Creating a View

    Hi,

    I have the following table structures:

    site_players
    id,
    name


    site_played
    id,
    players_id,
    match_id,
    goals,
    assists,
    pens


    site_match
    id,
    team


    In site_players I have a list of team members, in site_match I have a list of all games that have been played. I want to be able to query site_played the following:

    total number of games played, total goals, total assists and total pens.

    I've been looking at creating a view for this as I want to be able to order the query based on goals, assists or pens etc.

    Any help would be appreciated!!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    creating a view should come after you have completely tested and debugged the query

    if you need help with the query, let us know, but in the meantime, maybe you should go back and work on the table design first

    your site_match table looks a little deficient, it appears that a match consists of only one team

    why do all the tables have a site_ prefix?

    aren't players just players? what makes a site_player different from a player?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Aug 2009
    Posts
    2
    sorry, the tables are missing other fields that I simply do not require for this.

    The tables are prefixed with site_ as I have a large number of tables within the database all used for separate functions, so it's simply for human readability to find the tables associated with the website easier

    And yes you would be correct, I need help with writing the query. I'm stuck at the point where I need to total everything as I can currently return

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •