简体   繁体   English

SQL查询从数组中查找具有尽可能多匹配的ID

[英]SQL Query to find ID's with as many hits as possible from an Array

English is not my native language so i'll try to explain as good as i can. 英语不是我的母语,所以我会尽力解释。

I have a table with ID's in this table i also have account numbers. 我在此表中有一个ID为ID的表,我也有帐号。

something like this: 像这样的东西:

ID  ACCOUNT
1   1000
1   1001
1   1002
2   1000
2   1001
3   1003

then i have an array (Posted from a form, like name="array[0]",name="array[1]",name="array[2]"...) with these account numbers: 然后我有一个带有这些帐号的数组(从表单发布,例如name =“ array [0]”,name =“ array [1]”,name =“ array [2]” ...):

1000
1001
1002
1003

Now i want the query to get the ID's with the most "hits": 现在,我希望查询获得“点击次数”最多的ID:

1 = 3 out of 4
2 = 2 out of 4
3 = 1 out of 4

so with this query i need to get: 所以通过这个查询,我需要得到:

1 for 1000, 1001 and 1002
3 for 1003

Kind off confusing? 有点困惑吗? :) :)

Any suggestions? 有什么建议么?

SELECT COUNT( ID )AS从表1命中到GROUP BY ACCOUNT WHERE IN Account((1000,1001,1002)ORDER BY在命中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM