#1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'stack_wordpress.wp_postmeta.meta_value' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
#1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'stack_wordpress.wp_postmeta.meta_value' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
这个错误是因为在使用 GROUP BY 时, ORDER BY 子句包含了非聚合列 meta_value。这在 ONLY_FULL_GROUP_BY 模式下是不允许的。
解决办法:
临时禁用 ONLY_FULL_GROUP_BY 模式,以便查询能够执行
SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
评论 (0)