I'm pretty sure it is a very simple question but I'm new to mysql so I would appreciate some help.. I would like to use the following table in order to count how many times each item is registered for each ID, and generate a new table from there with columns corresponding to each distinct item (a count vector for each ID). So for example, having this:
ID ITEM
-----------------
0001 345
0001 345
0001 120
0002 567
0002 034
0002 567
0003 567
0004 533
0004 008
I want this:
ID 008 034 120 345 533 567
----------------------------------------------
0001 0 0 1 2 0 0
0002 0 1 0 0 0 2
0003 0 0 0 0 0 1
0004 1 0 0 0 0 0
Thank you