我正在开发一个名为PHP-Bouncer的开源项目,我正在为它编写的 MySQL 查询遇到问题。基本上我们有三个表:BouncerRoles、PageInRole 和 BouncerPageOverrides。BouncerRoles 包含访问级别,另外两个表通过外键链接回 BouncerRoles 并提供多个附加数据条目。我编写了以下查询来尝试一次提取我需要的所有角色数据:
select BouncerRoles.RoleID, BouncerRoles.RoleName,
GROUP_CONCAT(PageInRole.PageName separator '|') as ProvidedPages,
GROUP_CONCAT(CONCAT(BouncerPageOverrides.OverriddenPage,'&',BouncerPageOverrides.OverridingPage) separator '|') as OverriddenPages
from BouncerRoles join PageInRole on BouncerRoles.RoleID = PageInRole.RoleID
join BouncerPageOverrides on BouncerRoles.RoleID = BouncerPageOverrides.RoleID
group by BouncerRoles.RoleID;
此查询的目标是提供 RoleID、RoleName、一个管道分隔的提供页面列表和一个管道分隔的覆盖列表(以 overriddenpage&overridingpage 的形式)。一切正常,除了查询的最后一列,它像这样一遍又一遍地重复它找到的条目(以 CSV 格式输出):
RoleID,RoleName,ProvidedPages,OverriddenPages
2,Exchange,exchange-how.php|exchange-support.php|exchange.php|premium-promo.php|exchange-resorts.php|premiumplus-promo.php|exchange-deposit.php|exchange-requestdestination.php,whyexchange.php&exhange.php|whyexchange.php&exhange.php|whyexchange.php&exhange.php|whyexchange.php&exhange.php|whyexchange.php&exhange.php|whyexchange.php&exhange.php|whyexchange.php&exhange.php|whyexchange.php&exhange.php
3,Premium,premiumplus-promo.php|premium-cruises.php|premium-resorts.php|premium-condohome.php|premium-hotelaircar.php|premium.php|premium-restaurants.php|premium-overview.php,premium-promo.php&premium.php|premium-promo.php&premium.php|premium-promo.php&premium.php|premium-promo.php&premium.php|premium-promo.php&premium.php|premium-promo.php&premium.php|premium-promo.php&premium.php|premium-promo.php&premium.php
4,"Premium Plus",premiumplus-exclusiveescapes.php|premiumplus.php|premiumplus-overview.php|premiumplus-concierge.php|premiumplus-airportlounge.php,premiumplus-promo.php&premiumplus.php|premiumplus-promo.php&premiumplus.php|premiumplus-promo.php&premiumplus.php|premiumplus-promo.php&premiumplus.php|premiumplus-promo.php&premiumplus.php
我在查询中做错了什么导致这种情况吗?