Welcome Guest, Not a member yet? Register   Sign In
database error when using DISTINCT and ORDER BY
#7

(This post was last modified: 05-09-2017, 08:37 PM by corey.)

guyz seems like you dont understand problem is with mysql version 5.7 needs change in code or change mysql 5.7 mode
by default in 5.7 one mode is set to ONLY_FULL_GROUP_BY either disable it or go back to old 5.6 mysql
i fixed this problem by disabling only full group by

now here is what is happening and how it can be fixed

Code:
SELECT message_user_name FROM cms_inbox GROUP BY message_user_id ORDER BY message_time DESC

this code shows error in mysql 5.7

Code:
Error Number: 1055

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.cms_inbox.message_user_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by


how to fix it simply go back to mysql 5.6 or disable ONLY_FULL_GROUP_BY mode

seems like no one use group by regularly in codeigniter thats why no fixed querying in codeigniter which cause error in latest version of mysql 5.7 while works with every db before it

thank you guys my problem solved by disable ONLY_FULL_GROUP_BY but hoping for future proof codeigniter team fixes this query by making it compatible with mysql 5.7 or giving lil info how to setup query to use it with newer mysql

here is more info about this mode mysql 5.7
Reply


Messages In This Thread
RE: database error when using DISTINCT and ORDER BY - by corey - 05-09-2017, 08:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB