» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > MySQL Forums

MySQL Forums Share Your Ideas and Tips about MYSQL. Ask questions about MYSQL. Table Design and Much More...

Reply
 
Thread Tools Display Modes
  #1  
Old 07-30-2006, 10:46 AM
vibrant vibrant is offline
OSP Addicts
 
Join Date: Jul 2006
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 18
vibrant will become famous soon enough
Unhappy Mysql search querry

I have a table called 'games' for a football website. This table contains information, results and statistics about several football matches.

Among the fields in this table are 'goals' which contains the goalscorers in each match. Each goalscorer in this field are separated with a comma, like this


Code:
Player 1,Player 2,Player 3

Now, what I would like to do is to count all the goals that 'Player 1' has scored. In other words, count all the games where field 'goals' contains 'Player 1'. I've tried something like the below, but that obviously didn't work, as it only returns the games where field 'goals' ONLY contains 'Player 1' and no other names.


Code:
SELECT FROM games WHERE goals = 'Player 1'

Has anyone got a clue on how to do this? And, is it even possible to do it this way, or do I have to make a separate table with all the goalscorers in separate rows? -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 07-30-2006, 10:49 AM
uruguay uruguay is offline
OSP Starters
 
Join Date: Jun 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
uruguay is on a distinguished road
Lightbulb

Hey vibrant

Yes what you would do is normalize your table instead of doing it the way you are. Do not store multiple values in a single column.

Create a table with say gameid and playerid in it and list a single row for each playerid and the gameid he scores a goal in. If Ronaldo scores three times in a match he would have rows in the table for instance.

If you show the layout of your table(s) I or someone else can take a look and see if you need to normalize anything else.

hope it helps -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The future of Internet: Real-time Web Search and the Semantic Web waqar Premium Webmaster Articles 0 10-30-2006 07:41 AM
Oracle Unveils Oracle Secure Enterprise Search 10g outsourcingplans Web Hosting Industry 0 03-03-2006 05:42 PM
Navisso Search Launches Beta Test outsourcingplans Web Hosting News 0 01-04-2006 03:58 PM
MySQL 5.1.3-alpha has been released gunet MySQL Forums 0 12-09-2005 04:55 AM
Google Personalized Search Unleashed! outsourcingplans Web Hosting News 0 12-01-2005 04:44 PM


All times are GMT. The time now is 08:15 PM.