开发者

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜