lukep11a Posted July 4, 2011 Share Posted July 4, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/241087-update-table-query/ Share on other sites More sharing options...
fenway Posted July 6, 2011 Share Posted July 6, 2011 Why 12 columns of teams? Quote Link to comment https://forums.phpfreaks.com/topic/241087-update-table-query/#findComment-1238970 Share on other sites More sharing options...
lukep11a Posted July 6, 2011 Author Share Posted July 6, 2011 to store the 12 selections made by each user, there is also another column called userid Quote Link to comment https://forums.phpfreaks.com/topic/241087-update-table-query/#findComment-1239003 Share on other sites More sharing options...
xyph Posted July 6, 2011 Share Posted July 6, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/241087-update-table-query/#findComment-1239057 Share on other sites More sharing options...
mikosiko Posted July 6, 2011 Share Posted July 6, 2011 seems a duplicated post from this http://www.phpfreaks.com/forums/index.php?topic=337858.msg1592091#msg1592091 Quote Link to comment https://forums.phpfreaks.com/topic/241087-update-table-query/#findComment-1239061 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.