i am running this query `select individual_Ratings...
# sql
g
i am running this query
select individual_Ratings.*,count(rating) as tRating from individual_Ratings where productID = 99 group by rating
and my query is giving me an error on this
Copy code
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'shopzone1.individual_Ratings.individualid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
d
Yeah exactly what websolute said.
Don’t use *
Select only the necessary columns and add them to the group by clause
d
I think this happened to a lot of people with legacy projects (myself included) - I'm guessing you've recently updated your MySQL and you suddenly started getting this error. MySQL used to let this slide in prior versions and "it just worked" and that's why they included the flag
sql_mode=only_full_group_by
as from version 8. The correct answer is to modify your SQL as has been said by the group but if you can change that flag as a temporary workaround.
s
If your version of MySQL supports window functions, you can use that to do what you're trying to do.