原创

MySQL-group by-报错-sql_mode=only_full_group_by


SELECT list is not in GROUP BY clause and contains nonaggregated column ‘xxxx’
which is not functionally dependent on columns in GROUP BY clause;
this is incompatible with sql_mode=only_full_group_by

SELECT
container_id,
user_id
FROM
edu_user_online_course_status s
WHERE
user_id = "admin_51"
GROUP BY
user_id ;
改成子查询【未在相应的环境测试】
SELECT
( SELECT container_id FROM edu_user_online_course_status WHERE user_id = s.user_id LIMIT 1 ) AS container_id,
user_id
FROM
edu_user_online_course_status s
WHERE
user_id = "admin_51"
GROUP BY
user_id;
正文到此结束
本文目录