I have 2 tables like this :
category_table:
data_id cat_id
1 1
1 2
3 1
3 3
4 5
4 6
data_table:
data_id example_data
1 x
2 y
3 m
4 i
what I need is to count number of data_table records that are grouped with category 1 AND 2
Edit: After re-reading your question, is this what you’re looking for? A count of elements from data_table where there exists an entry in the category_table for both categories 1 and 2?
(old answer below this…)
If you want a straight count of all records:
If you want a count for each category: