1
SELECT xp.productid, xp.product, xc.classid, xiW.date, xco.optionid, xco.option_name, xiW.id, xiW.image_path, xiW.path_on_server
    FROM xcart_products xp
    INNER JOIN xcart_variants xv ON xp.productid = xv.productid
    INNER JOIN xcart_variant_items xvi ON xv.variantid = xvi.variantid
    INNER JOIN xcart_class_options xco ON xvi.optionid = xco.optionid
    INNER JOIN xcart_classes xc ON xco.classid = xc.classid AND xc.class = 'COLOR'
    LEFT JOIN xcart_images_W xiW ON xiW.id = xvi.variantid
    GROUP BY xco.optionid
    ORDER by xp.product ASC

我收到错误说明:xp.productid 不在 GROUP BY 中

然后我添加它并得到 xp.product is not in GROUP BY

我添加它并得到 xc.classid 不在 GROUP BY 中

我添加了它并一直向下走 -

SELECT xp.productid, xp.product, xc.classid, xiW.date, xco.optionid, xco.option_name, xiW.id, xiW.image_path, xiW.path_on_server
    FROM xcart_products xp
    INNER JOIN xcart_variants xv ON xp.productid = xv.productid
    INNER JOIN xcart_variant_items xvi ON xv.variantid = xvi.variantid
    INNER JOIN xcart_class_options xco ON xvi.optionid = xco.optionid
    INNER JOIN xcart_classes xc ON xco.classid = xc.classid AND xc.class = 'COLOR'
    LEFT JOIN xcart_images_W xiW ON xiW.id = xvi.variantid
    GROUP BY xco.optionid, xp.productid, xp.product, xc.classid, xiW.date, xco.option_name, xiW.id, xiW.image_path, xiW.path_on_server
    ORDER by xp.product ASC

这不可能是正确的吧?它确实可以运行,但我认为 GROUP BY 在 MySQL 5 中的处理方式与 MySQL 4 中的处理方式略有不同,或者我的查询在四个中几乎没有功能?

4

1 回答 1

2

显然您已启用ONLY_FULL_GROUP_BY模式

只需禁用它,您就可以再次对这个出色的 mysql 扩展感到满意GROUP_BY

于 2012-12-14T21:07:52.037 回答