i have a MySQL table with the username and bought items. Likeā¦
Username1 - Item_A
Username1 - Item_A
Username2 - Item_C
Username2 - Item_D
Username1 - 1
Username2 - 2
You can group by the user and apply a distinct count to the items:
SELECT username, COUNT(DISTINCT item)
FROM mytable
GROUP BY username