Jump to content

eciym

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

eciym's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thankyou very, very much Keith you have saved me from a monster migrane!
  2. MySQL 5.0.27 hej, I was wondering if some of you wonderful people could give me a heads up on this, I have been reading up and have summised that I need a LEFT JOIN As i want it to list all the teams regardless of if they have points or not. I have a table of teams with a UID and the team name. then i have a table called points that stores the UID of the teams table as a foreign key, the number of points and each entry is timestamped for historical review later on. what I want to do is display all the teams and the total number of points each team has acrued. I get the sum of the teams with this $query = "SELECT pointsfid, SUM(teampoints) FROM points GROUP BY pointsfid"; I presumed that being a relational database i wouldnt have to save the team name in the points table. Assumed it would be possible to get the team names also. but how to get a query to display the team as well has foxed me. I got this far SELECT pointsfid, SUM(teampoints) AS totalpoints FROM points GROUP BY pointsfid LEFT JOIN teams ON points.pointsfid = teams.teid was I even close? miles out? what did I miss? This seems like it should be so simple. Am I barking up the wrong tree? should I be looking to create a totals feild in the teams table and update that with a total from the points table. to me that seems like it shouldnt be needed. another question pops in to my head also; How do I echo the alias totalpoints in PHP? Thanks in advance for any help with this.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.