TechSpott - Computer and technology forums

Go Back   TechSpott - Computer and technology forums > Webmasters > Database Management > MySQL
MySQL Forum dedicated to the world's most popular open source database engine.

Reply
 
Thread Tools Display Modes
Old April 12th, 2010, 01:17 AM   #1 (permalink)
Grizzley G
Guest
 
Posts: n/a
Default MySQL table join (joining a column from one table to the row of another more like)?

OK, here's something complex that I am doing (complex for me, mostly not for y'all who've been doing this for a while).

I want to have a table in which I am indexing a person name, userID, pass, points earned on a game. Now over the course of 5 months, let's say we have 10 games.

What I wish to do is find an average after each game has been played. Supposing all gamesa re worth 100 points each, and if the person got 56 in the first game and 98 in the next, his total would be 56+98/2. And that is the number I wish to display when the person logs in to his account.

Now, I have the login and all setup, and I also have the database setup with one table that deals with the name, userID, and "expectedpoints" and "achievedpoints"
原帖地å€: TechSpott - Computer and technology forums http://www.techspott.com//showthread.php?p=6491

The problem is, I cannot have a single table and keep on inputting scores from different games into a given row that has columns corresponding to a person named, Joe, let's say, or someone else.

So I'd have to join two tables for this purpose, wouldn't I? So, how would I join the two tables, and how would the structure of my second MySQL table look like if I wanted to have 10 rows (or colums?) for the 10 games that Joe would play, and then, average it out? I know that SUM(points) doesn't apply to rows so I would have to have an entire column which will display the points earned solely by Joe, and then select that column. But how do I select that column, I mean how would I set up a primary key for a column to distinguish it from the rest that "this column belongs to Joe and all the points have to be tallied only for Joe cuz he's the guy that has just logged in"?

Again, in a simpler way, I just wish to echo (not literally as is given-->) "sum(achievedpoints) / COUNT(*) achievedpoints FROM points)", but from my table which would contain numerous people's points, how do I point out to the one that deals with Joe's points when Joe logs in and wants to see his points?

Uh, I hope I was clear. REALLY thanks for any, any, _any_ help that I will receive!
  Reply With Quote Share with Facebook
Reply

Bookmarks

Tags
column, join, joining, mysql, row, table


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I take a column in one MYSQL table, and insert it into another table (but... NicholasD MySQL 0 April 11th, 2010 09:42 PM
Mysql Join Help for using two tables in one Query? Blue MySQL 0 April 4th, 2010 09:52 AM
Sorting PHP MySQL table by links? christopher wood MySQL 1 April 4th, 2010 02:59 AM
How to insert a list from a text file into mysql table ? London MySQL 0 April 2nd, 2010 01:51 AM
How do I make my MySQL table automatically make a timestamp when new data is added? Carbonbased Lifeform MySQL 0 March 31st, 2010 03:40 PM

 
Forum Stats
Members: 14,372
Threads: 20,381
Posts: 27,861
Total Online: 47

Newest Member: VanyaDog

Latest Threads

Advertisements

Support our advertisers!

Amazon
Sears
Macys
1800flowers.com
Drugstore.com


Carbonite Online-Backups
Tiger Direct
Tech Depot
Buy.com
Office Depot
Fatcow
HostGator


TripsNow.us
Marriott
Expedia
CheapTickets.com
OneTravel
Hotwire

Are you a Fan?

Share this on Facebook

Tag Cloud

Partner Links


Contact Us - Home - Archive - Privacy Statement - Top - Copyright © 2009-2010, TechSpott - All times are GMT -4. Time is 08:08 PM

Powered by vBulletin® Copyright © Jelsoft Enterprises Ltd. :: SEO by vBSEO