Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL选择最高用户排名最高的组双打_Mysql_Integration_Inner Join - Fatal编程技术网

MySQL选择最高用户排名最高的组双打

MySQL选择最高用户排名最高的组双打,mysql,integration,inner-join,Mysql,Integration,Inner Join,我的问题是,在结果中,如果一个用户在一个以上的排名较高的组中,他可以在其中多次 SELECT xf_user_group_relation.user_id , xf_user_identity.account_name, xf_user_group_relation.user_group_id, MAX( xf_user_group.display_style_priority ) AS display_style_priority FROM xf_user_group_relation INN

我的问题是,在结果中,如果一个用户在一个以上的排名较高的组中,他可以在其中多次

SELECT xf_user_group_relation.user_id , xf_user_identity.account_name, xf_user_group_relation.user_group_id, MAX( xf_user_group.display_style_priority ) AS display_style_priority
FROM xf_user_group_relation
INNER JOIN xf_user_group ON xf_user_group_relation.user_group_id = xf_user_group.user_group_id
INNER JOIN xf_user_identity ON xf_user_group_relation.user_id = xf_user_identity.user_id
WHERE xf_user_group.display_style_priority >=1000 AND identity_service_id = 'Minecraft'
GROUP BY xf_user_group_relation.user_id, xf_user_group_relation.user_group_id, xf_user_identity.account_name
结果:

|user_id|account_name|user_group_id|display_style_priority|
|1|yuriman|5|10000
|1|yuriman|6|9000
|2|skull905|5|10000
|13|ryan1271|5|10000
|21|mr_matt|9|6000
|37|Gaurav251|12|1000
|38|tvmaniac9|9|6000
|38|tvmaniac9|11|2000
|44|robyrq|9|6000
|44|robyrq|12|1000
|86|sabasNL|11|2000
|86|sabasNL|15|5200
|128|Scarykittens|9|6000
|133|Sargent5|10|5000
|133|Sargent5|11|2000
|142|kevy76|9|6000
|142|kevy76|11|2000
|144|liljew29|10|5000
|144|liljew29|11|2000
|149|a7xtdgfan332|10|5000
|160|TheNeoStrike|11|2000
|189|CptToddney|11|2000
结果应该如下所示:

|user_id|account_name|user_group_id|display_style_priority|
|1|yuriman|5|10000
|2|skull905|5|10000
|13|ryan1271|5|10000
|21|mr_matt|9|6000
|37|Gaurav251|12|1000
|38|tvmaniac9|9|6000
|44|robyrq|9|6000
|86|sabasNL|11|2000
|128|Scarykittens|9|6000
|133|Sargent5|10|5000
|142|kevy76|9|6000
|144|liljew29|10|5000
|149|a7xtdgfan332|10|5000
|160|TheNeoStrike|11|2000
|189|CptToddney|11|2000
我希望结果只包含用户排名最高的组,即显示样式优先级最高的组。 我不知道如何解决这个问题


致以最诚挚的问候

我想您需要在

GROUP BY xf_user_group_relation.user_id, xf_user_identity.account_name

我认为你需要改变这个群体

GROUP BY xf_user_group_relation.user_id, xf_user_identity.account_name

尝试将group by更改为“group by xf\u user\u group\u Relationship.user\u id,xf\u user\u identity.account\u name”有效,您能否将其写为答案以便我可以接受?尝试将group by更改为“group by xf\u user\u group\u Relationship.user\u id,xf\u user\u identity.account\u name”有效,您能否将其写为答案以便我可以接受?