triphis Posted September 29, 2003 Share Posted September 29, 2003 Arg, stuck again >.> How do I add all the values in a COLUMN. Example: Name --- Age Zach --- 17 Jake --- 16 Jim --- 12 So how would I go about adding all the values in the AGE column? Also, what column type should I use? I currently have INT, but is there anything better? the true use of this information will use used on a column with 8 digits (12345678). Thanx Quote Link to comment https://forums.phpfreaks.com/topic/1082-mysql-column-addition/ Share on other sites More sharing options...
Barand Posted September 29, 2003 Share Posted September 29, 2003 To add the ages SELECT SUM(age) as total_age FROM mytable From MySql manual : the range of an INT column is -2147483648 to 2147483647. If you try to insert -9999999999 into an INT column, the value is clipped to the lower endpoint of the range, and -2147483648 is stored instead. Similarly, if you try to insert 9999999999, 2147483647 is stored instead. If the INT column is UNSIGNED, the size of the column\'s range is the same but its endpoints shift up to 0 and 4294967295. If you try to store -9999999999 and 9999999999, the values stored in the column become 0 and 4294967296. Quote Link to comment https://forums.phpfreaks.com/topic/1082-mysql-column-addition/#findComment-3683 Share on other sites More sharing options...
pauper_i Posted September 29, 2003 Share Posted September 29, 2003 Now there\'s one I didn\'t know! Thanks for the info! (Betcha I still get it wrong when it comes time to use it though!) D Quote Link to comment https://forums.phpfreaks.com/topic/1082-mysql-column-addition/#findComment-3685 Share on other sites More sharing options...
triphis Posted September 29, 2003 Author Share Posted September 29, 2003 Wow! Thank you Barand You are always a huge help! Quote Link to comment https://forums.phpfreaks.com/topic/1082-mysql-column-addition/#findComment-3692 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.