Jump to content

Recommended Posts

Hi, I have two tables, one called 'selections' with 12 columns each holding 1 team name, the other table is called 'teams' and in that table is a list of all 92 teams and the number of points they have so far. Is it possible to add up the points totals of the 12 teams in each row of the 'selections' table and store the result in another column?

Link to comment
https://forums.phpfreaks.com/topic/241087-update-table-query/
Share on other sites

fenway is probably thinking you should have a third table, that stores the userid, and teamid. Each userid can have 12 rows, each with a different teamid. Use PHP to make sure each userid shows up in the table no more than 12 times.

 

You wouldn't want to 'store' this value though. Perhaps temporarily cache it, and for that you'd probably want to use another MySQL table, with the date it was cached so you can see if it's stale and needs to be summed again.

 

Post a dump of your tables, and I'll show you how I'd do it.

Link to comment
https://forums.phpfreaks.com/topic/241087-update-table-query/#findComment-1239057
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.