我工作的一个开源项目PHP,蹦床 ,和我在与一个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;
这个查询的目标是提供角色ID,角色名,提供页面的管分隔的列表,和覆盖的管分隔的列表(在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
是不是我做错了我的查询导致此?