If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Creating a View

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-05-09, 09:03
peteoc peteoc is offline
Registered User
 
Join Date: Aug 2009
Posts: 2
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!!
Reply With Quote
  #2 (permalink)  
Old 08-05-09, 09:17
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-05-09, 09:22
peteoc peteoc is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On