Yammyguy Posted March 23, 2009 Share Posted March 23, 2009 I have a quick question with respect to calculations within a table. For example, let's use the following table: hour | load GT1 | load GT2 | load ST | total 1 | 30 | 30 | 0 | (sum of load GT1, GT2, ST) 2 | 40 | 20 | 3 | (sum of load GT1, GT2, ST) Is there a function or calculation I can add right in the mysql table under total, to automatically add the sum of the other columns? I'd like to have mysql do it instead of adding to the PHP code - maybe just to skip a few steps?? Let me know if you need any more information. Thanks in advance! ~C. Quote Link to comment https://forums.phpfreaks.com/topic/150664-calculations-from-within-a-table/ Share on other sites More sharing options...
trq Posted March 23, 2009 Share Posted March 23, 2009 SELECT GT1+GT2+ST as total Quote Link to comment https://forums.phpfreaks.com/topic/150664-calculations-from-within-a-table/#findComment-791516 Share on other sites More sharing options...
Yammyguy Posted March 23, 2009 Author Share Posted March 23, 2009 SELECT GT1+GT2+ST as total So if I'm creating the table in phpMyAdmin, would I put that right in the value of that cell? Quote Link to comment https://forums.phpfreaks.com/topic/150664-calculations-from-within-a-table/#findComment-791518 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.