COUNT(*) problem with GROUP BY
What I'm trying todo is count the total amount of rows that match a series of tags that are related to one or more user_ids.
I've noticed that the COUNT(*) operation returns the total amount of rows that were calculated for each group by label.
lets say that a user_id of 2 belongs to users_tags both in a record where the tag_id is 1 and 2.
SELECT user_id FROM users_tags WHERE tag_id IN (1,2)
I'm therefore going to end up getting two results.
SELECT user_id FROM users_tags WHERE tag_id IN (1,2) GROUP BY user_id.
Ok now I have 1 record (that's what I want), but when I run the count operation I get:
SELECT count(*) FROM users_tags WHERE tag_id IN (1,2) LIMIT 1
which gives me a value of two.
Now lets say that user_id of 3 also belongs to both tags.
then I'll get a count(*) of 4, but when I select columns I get two rows (which is the total count that I want).
How do I count the total amount of rows (using COUNT(*)) with a group by operation for this situation?