mysql-error-1055

Select list contains nonaggregated column

谁说我不能喝 提交于 2020-01-01 14:39:48
问题 Since updating MySQL I've noticed the following query fails SELECT u.*, p.name as plan, COUNT(u.id) as totalprojects FROM users u LEFT JOIN plans p ON p.id = access LEFT JOIN maps m ON m.user_id = u.id WHERE u.email = 'john@doe.com' In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'kontakt.u.id'; this is incompatible with sql_mode=only_full_group_by Does anyone know how to get this query fixed to sort the error? 回答1: You can do one of two things

How to fix query group with only_full_group_by

北城余情 提交于 2020-01-01 14:18:07
问题 I have a basic key-value table, that has some data in it for each user. With the updated mysql it has the sql_mode set to only_full_group_by (new default) when you do a group by. When I try to run this simple query: select * from user_features where user_id = 1 group by feature_key I get the following error: SQL Error (1055): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'date.user_features.user_id' which is not functionally dependent on columns in

Query with GROUP BY and ORDER BY not working when multiple columns in SELECT are chosen

烈酒焚心 提交于 2019-12-24 07:58:30
问题 I'm updating an old website and one of the queries isn't working anymore: SELECT * FROM tbl WHERE col1 IS NULL GROUP BY col2 ORDER BY col2 I noticed if I dropped the GROUP BY it works, but the result set doesn't match the original: SELECT * FROM tbl WHERE col1 IS NULL ORDER BY col2 So I tried reading up on GROUP BY in the docs to see what might be the issue, and it seemed to suggest not using * to select all the fields, but explicitly using the column name so I tried it with just the column

MySQL incompatible with sql_mode=only_full_group_by

和自甴很熟 提交于 2019-12-12 01:52:34
问题 I have the following query (UPDATED SEE BELOW): SELECT i0_.id AS id_0, i0_.address AS address_1, i1_.name AS name_2, c2_.name AS name_3, c3_.code AS code_4, l4_.iso AS iso_5, c5_.id AS id_6, c6_.name AS name_7, i7_.identifier AS identifier_8 FROM institutions i0_ LEFT JOIN institution_languages i1_ ON (i1_.institution_id = i0_.id) LEFT JOIN countries c3_ ON (c3_.id = i0_.country_id) LEFT JOIN country_languages c2_ ON (c2_.country_id = c3_.id) LEFT JOIN country_spoken_languages c8_ ON (c8_

MySql 5.7 ORDER BY clause is not in GROUP BY clause and contains nonaggregated column

僤鯓⒐⒋嵵緔 提交于 2019-12-11 07:36:29
问题 I'm trying to figure out without disabling "only_full_group_by" in my.ini here is my query: SELECT p.title, COUNT(t.qty) AS total FROM payments t LEFT JOIN products AS p ON p.id = t.item WHERE t.user = 1 GROUP BY t.item ORDER BY t.created DESC; and tables: Payments: id item user created ============================ 1 1 1 2017-01-10 2 2 1 2017-01-11 3 3 1 2017-01-12 4 4 1 2017-01-13 5 1 1 2017-01-14 Products: id title created ========================== 1 First 2016-12-10 1 Second 2016-12-11 1

Select list contains nonaggregated column

喜你入骨 提交于 2019-12-04 14:43:53
Since updating MySQL I've noticed the following query fails SELECT u.*, p.name as plan, COUNT(u.id) as totalprojects FROM users u LEFT JOIN plans p ON p.id = access LEFT JOIN maps m ON m.user_id = u.id WHERE u.email = 'john@doe.com' In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'kontakt.u.id'; this is incompatible with sql_mode=only_full_group_by Does anyone know how to get this query fixed to sort the error? You can do one of two things: 1) change your query so that everything in the select clause is aggregated. Something like this SELECT u

MySQL Error: SELECT list is not in GROUP BY clause

穿精又带淫゛_ 提交于 2019-11-29 16:54:35
I have a problem with my query and mysql throws the following error: #1055 - Expression #66 of SELECT list is not in GROUP BY clause and contains nonaggregated column 's.status' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by Query is: select p.*, pd.*, m.*, IF(s.status, s.specials_new_products_price, null) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price FROM products p LEFT JOIN specials s ON p.products_id = s.products_id LEFT JOIN manufacturers m using

MySQL Group By functionality in different version

十年热恋 提交于 2019-11-29 11:39:55
Following is a simple SQL query: SELECT * FROM *table_name* GROUP BY *column_name* In my system I have MySQL 5.5. It is working absolutely fine. Whereas in my friend's system he have MySQL 5.7, and he is getting the following error: ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'testdb.assetentry.entryId' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by It is clearly visible this is happening because the versions are different. But what I want to know is the

MySQL Error: SELECT list is not in GROUP BY clause

大兔子大兔子 提交于 2019-11-28 11:35:55
问题 I have a problem with my query and mysql throws the following error: #1055 - Expression #66 of SELECT list is not in GROUP BY clause and contains nonaggregated column 's.status' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by Query is: select p.*, pd.*, m.*, IF(s.status, s.specials_new_products_price, null) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price FROM

MySQL Group By functionality in different version

南楼画角 提交于 2019-11-28 05:13:56
问题 Following is a simple SQL query: SELECT * FROM *table_name* GROUP BY *column_name* In my system I have MySQL 5.5. It is working absolutely fine. Whereas in my friend's system he have MySQL 5.7, and he is getting the following error: ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'testdb.assetentry.entryId' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by It is