I have a MySQL view with the fields id and set. Because it's a view, most ids are repeated and have duplicate entries. For example, and id = 120158 may have 5 rows, 3 where set = A and 2 where set = B. I want to run a query off of the view to display the number of rows each id has associated with its corresponding sets.
I tried:
SELECT `id`,
`set`,
(SELECT COUNT(set)) AS `CountOfSet`
FROM `view1`
However, this simply returns the same view (duplicate rows still exist) with CountOfSet equal to 1 for every row. Any ideas?