14.10.2014, 10:26
It should work with SUM if your table is structured correctly. How is the table built up?
If it's built like "item1, item2, item3 ..." then that's not the correct way to do it, and SUM will not work. SUM only counts vertically through a single column, not horizontally. To normalize it correctly, you need at least one extra table, possibly two.
One table (let's say "player_items") with these two (or three) columns:
userid, itemid and optionally an amount
Another table can list the items, but this is not mandatory:
itemid, description, default_amount, ...
In "player_items" you then combine data from your main player and data from the item table. Then you will be able to count them correctly.
If it's built like "item1, item2, item3 ..." then that's not the correct way to do it, and SUM will not work. SUM only counts vertically through a single column, not horizontally. To normalize it correctly, you need at least one extra table, possibly two.
One table (let's say "player_items") with these two (or three) columns:
userid, itemid and optionally an amount
Another table can list the items, but this is not mandatory:
itemid, description, default_amount, ...
In "player_items" you then combine data from your main player and data from the item table. Then you will be able to count them correctly.