sql - MySQL Count presence of multiple values in same column -


i have single table called customers custid column , column called productcode. there 33 possible products (numbered 1 33) , each customer can have combination of products. there single row each customer , of products each customer has shown in productcode column space in between i.e:

custid     productcode   ------     -----------  001        3 12 18 22 32   002        9 6 18 36   003        3 6 7 26   004        9 11 33    005        6 21 28 29 30 31   006        1 3 6 21 30 31   

i need able count of each product , add text description of code:

prodcode    description       count   ~~~~~~~~    ~~~~~~~~~~~       ~~~~~   1           lawnmower         1   3           spade             3   6           clippers          4   etc 

thanks!

never, never, never store multiple values in 1 column!

as see result in problems. please normalize db structure additional table

customer_products custid     productcode   ------     ----------- 001        3 001        12 001        18 --- 002        9 002        6 ... 

then can remove productcode column customer table.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -