MySQL: Using a reference id, see if data matches across that id
I have the following table
开发者_运维技巧id | data | reference_id
1 Jacob 3
2 Apples 3
3 Henry 4
4 Pie 4
5 Jacob 5
6 Pears 5
What I'm trying to do is build a query that checks if data exists in the same reference_id given the data.
So basically:
SELECT COUNT(*) WHERE data='Jacob' AND data='Apples' AND
...(reference_id's are the same)
SELECT COUNT(*) WHERE data='Jacob' AND data='Apples' GROUP BY reference_id;
精彩评论