查询不再适用于MySQL 5

时间:2012-12-14 20:53:44

标签: mysql database mysql5

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不在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中的处理方式有点不同于4或者我的查询在四个方面几乎没有功能?

1 个答案:

答案 0 :(得分:2)

显然您已启用ONLY_FULL_GROUP_BY模式

只需禁用它,您就可以再次对GROUP_BY

这个出色的mysql扩展感到满意