今天公司把 mysql 从 5.6 升级到 5.7 后,报错 1055:Expression #18 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'wechat_data.mal.create_time' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 。我查了下大部分的回答都是改 mysql 配置的,主管不让改配置。请问 V 友如何在不改配置只改 sql 语句使其正常运行呢?
以下是 sql 语句: SELECT mp.id, mp.mp_name, mp.weixinname, mp.biz, ifnull(mp.head_img_url, '') AS head_img_url, ifnull(mp.qr_code_url, '') AS qr_code_url, mp.introduce, mp.company_name, mp.first_average_num, mp.average_num, mp.souce_mp, mp.souce_article, mp.is_auth, mp.push_num, ifnull(mp.update_time, '') AS update_time, ifnull(mp.create_time, '') AS create_time,
IF (mal.biz 'null', 1, 0) AS is_storage,
ifnull(mal.create_time, '') AS import_time,
ifnull(art.read_num, 0) AS read_num,
ifnull(art.like_num, 0) AS like_num
FROM
wd_mp_library
mp
LEFT JOIN wd_mp_library_formal mal ON mp.biz = mal.biz
LEFT JOIN wd_mp_library_about_articles art ON mp.biz = art.biz
WHERE
mp.isdel = 0
GROUP BY
mp.id
ORDER BY
mp.update_time DESC,
mp.create_time DESC,
art.read_num DESC
LIMIT 0,
20
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.