JeRRy wrote:
Hi,

I have 23 tables, well I have more but these 23 tables
are the main agenda regarding this question.

In each of the table is a column titled "score" and a
column titled "nickname" ... These are the two columns
we need for this.
[snip]
Now I want the scores added up.  So using the + not *
(times) but just adding.  So for Bob is 5 + 3 = 8 and
this figure must than be placed in another table with
that name.

What I want to do is just have one code written up so
I don't need to change it.  So in other words the code
would include all 22 tables and the method to add each
other together and update to the actual main scoring
table.

So the score aRE updated once a week.  I don't mind if
I need to trigger the update (preffered) from a php
page/script.  That's not the problem but I want to
know what code I would use to grab these details and
add them up using all 22 tables in the one script.  So
each time the script is ran it will re-calculate all
tables to make sure they are correct if an update is
made to a score.

So the script would grab all 22 tables score and
nickname and than match the nickname and update their
score in the scoring table.

What I have is this:

My Tables are round 1 through to round22 and the
scoring totals go into table called tipping.

So round1 through to 22 need to be calculated and
keeping the totals for each nickname correct with
their totals.  Don't want the scores to be jumbled
with a different nickname.

How would I do this that would be a pretty fast
process and reliable?

If you need more information please let me know.  Each
round table will have identical Nicknames in each,
none will have more or few, same amount.

Keeping in mind each round that has not had a total
set is defaulted as nothing in the score field, it's
blank.  But if it's required to have a value of 0 in
there for the calculations to work I can default this
in.

If anyone can help me here it would be great, I have
been stuck on this for a while. There is only going
to be like 15 names max in each round to do totals for
so it's not a huge database.


Thanks for your time.
[snip]
well - two options spring to mind...

1) use a single table, with 23 columns instead of 2. Then sum the columns in your query.
- 1 query, no loops required.
2) have your script pull everything and add it all up.
- 22 queries, a loop for each, array storing scores & indexed by name.


anything else is going to be a join from hell. With only 22 tables and 15 rows in each table, you literally won't be able to blink before either of these methods would be finished calculating your totals.

Whatever you code up will be as reliable as the code used for it :)

A better question to ask is, will this be something that cycles yearly or regularly? If so, you'll want to be storing some identifier for the event/session/quarter/year/etc. - in which case any join option would be insanely further compliated, and all of your queries would need the chunk added.

Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to