Skip to content

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

Open
@threehappypenguins

Description

@threehappypenguins

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions