我有这个大选择,问题是来自不同表的2个GROUP_CONCAT。如果我从选择颜色显示normaly删除描述,如果我保持它像这个颜色显示x3次。
SELECT
DISTINCT m.model as model
,m.price as price
,m.size as size
,m.colorsetIDMainBag as mainColor
,GROUP_CONCAT(colorset.name) AS color
,leather.name AS leather
,leather.nameUA AS leatherUA
,leather.nameRU AS leatherRU
,GROUP_CONCAT(description.descriptionUA) AS descriptionUA
,GROUP_CONCAT(description.descriptionRU) AS descriptionRU
,GROUP_CONCAT(description.descriptionEN) AS descriptionEN
FROM
bags as m
LEFT OUTER JOIN colorpack
on m.bagsID=colorpack.colorpack
LEFT OUTER JOIN color
on colorpack.colorID=color.colorID
LEFT OUTER JOIN colorset
on color.colorsetID=colorset.colorsetID
LEFT OUTER JOIN leather
on color.leatherID=leather.leatherID
LEFT OUTER JOIN descriptionpack
on m.bagsID=descriptionpack.descriptionpack
LEFT OUTER JOIN description
on descriptionpack.descriptionID=description.descriptionID
WHERE
colorpack.colorpack='62'
GROUP BY model
答案 0 :(得分:4)
尝试
GROUP_CONCAT(DISTINCT colorset.name) AS color
我认为你知道你正在使用GROUP BY
的非标准MySQL扩展,这通常会产生不可预测和奇怪的结果。如果您不知道,请阅读此内容。
http://dev.mysql.com/doc/refman/5.1/en/group-by-extensions.html