abhinavsingh89 Posted May 9, 2010 Share Posted May 9, 2010 guys i hv a table stock which consist of itemid,name, i have another table received which have itemid(foreignkey to stock itemid), qty.. nw in my last module what i have done is i allowed user to enter quantity which will sum up to the previous quantity.. for ex if i had 10 items nd user enter 12 then new amt of items will be 22.... but unfortunately i created a new record for that ... that is a new record will be entered with same itemid and qty 12....i submitted my that module also so cannot make any change in that... now when i apply join it shows redundant entries....now i just want to sum up all the records (i.e. qty) available for particular itemid and print the total qty available.. can anyone suggest a solution to this... thnx in advance... Quote Link to comment https://forums.phpfreaks.com/topic/201184-adding-values/ Share on other sites More sharing options...
Mchl Posted May 9, 2010 Share Posted May 9, 2010 Aggregating functions to the rescue! SELECT itemid, SUM(qty) AS qty FROM received WHERE ... GROUP BY itemid Quote Link to comment https://forums.phpfreaks.com/topic/201184-adding-values/#findComment-1055534 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.