johnhendy
|
| Posted: 12/12/2004, 12:19 PM |
|
Hi, 
I wonder if any one can help? I am quite new to mysql and php and have managed to get
along. I have come up against a rather strange occurrence produced by mysql. I have 2
tables, one called coursecard and the other called courseback. The fields within the
tables are identical. The Coursecard table contains details of the first nine holes of a
golf course and the courseback table contains details of the last nine holes. I didn't set
the tables up and I cant change them because they are used else where on a website.
So what I managed to do, was sum the first nine holes and arrive at a total, thenthe same
to the last nine. All Ok at this point. Now I need to sum the total of the first nine and
the last nine and provide a total for all 18 holes.
This is how I got totals from the coursecard
SELECT (SUM(blueyards)) as TOTAL1, (SUM(whiteyards)) as TOTAL2,
(SUM(yellowyards)) as TOTAL3, (SUM(menspar)) as TOTAL4,
(SUM(redyards)) as TOTAL5,
(SUM(ladiespar)) as TOTAL6
FROM coursecard
And this is the results for The coursecard blueyards = 3062
This is how I got totals from the courseback
SELECT (SUM(blueyards)) as TOTAL7, (SUM(whiteyards)) as TOTAL8,
(SUM(yellowyards)) as TOTAL9, (SUM(menspar)) as TOTAL10,
(SUM(redyards)) as TOTAL11,
(SUM(ladiespar)) as TOTAL12
FROM courseback
And this is the results for The courseback blueyards = 3048
Now I need to aquire the total of the two blueyards as well as the rest of the fields, but
this is where I have had some strange values appear, which obviously tells me I am doing
something wrong. Can anyone help, it should be simple, but I am stuck.
I used the following statement to aquire both totals again but this time add them
together.
SELECT (SUM(coursecard.blueyards) + (SUM(courseback.blueyards))) as TOTAL1
FROM courseback,coursecard
And this is the results for The above statement blueyards Total = 27558 
looking forward to you assistance.
|
|
|
 |
klwillis
Posts: 428
|
| Posted: 12/13/2004, 10:54 AM |
|
What is the 'where clause' you are using for the combined
summation in the second select statement?
~~~
I used the following statement to aquire both totals again but this time add them
together.
SELECT (SUM(coursecard.blueyards) + (SUM(courseback.blueyards))) as TOTAL1
FROM courseback,coursecard
And this is the results for The above statement blueyards Total = 27558
looking forward to you assistance.
_________________
Kevin Willis, VP/CIO
HealthCare Information Technology Specialist
http://www.nexushealthcare.com
"Fast - Convenient - Quality-Care"
Medical Software Consulting Services
Email : klwillis@nexushealthcare.com
Skype : klwillis2006 |
 |
 |
johnhendy5
Posts: 12
|
| Posted: 12/14/2004, 4:54 AM |
|

Hi, Just to let you know there is no where clause in the statement. This is because I am not sure what it should be. Stupid I know.
_________________
Thanks |
 |
 |
|