Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5. Get all Bands that have No Albums - sql_mode=only_full_group_by #25

Open
threehappypenguins opened this issue Aug 3, 2024 · 0 comments

Comments

@threehappypenguins
Copy link

threehappypenguins commented Aug 3, 2024

Since Workbench seems to have been done away with, I had installed the 8.4 server and the 8.0.38 workbench. Apparently with the 8.4 server, sql_mode=only_full_group_by is enabled by default. The problem with this is that

SELECT bands.name AS 'Band Name'
FROM bands
LEFT JOIN albums ON bands.id = albums.band_id
GROUP BY albums.band_id
HAVING COUNT(albums.id) = 0;

Does not work:

Error Code: 1055. Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
'record_company.bands.name' which is not functionally dependent on columns in GROUP BY clause;
this is incompatible with sql_mode=only_full_group_by

bands.name is a non-aggregated column in the SELECT statement. The solution, I think, is changing GROUP BY albums.band_id to GROUP BY bands.id, bands.name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant