Group by is problematic since I switched to PHP 7 and having aggregate values doesn't apply to the way I want to use it.
I've got a list and sometimes there are repeats in the list. For example:
Song Title A Song Title B Song Title A (reprise) Song Title C
In the results, Song Title A should only show up once. Previously, I had done this with group by, where the ID that determines the song title is grouped.
My table structure is:
id
group_id
song_title_id
Song_title_id relates to:
id
song_title
In the first table, there can be multiple instances of the same song_title_id. And when results are returned, I want there to only one instance of each song_title_id in the results.
Previously, I'd have done:
DB::table('group_songs')
->groupBy('song_title_id')
->get();
Since updating to PHP 7, I get an error:
Syntax error or access violation: 1055 '[table/column name]' isn't in GROUP BY
What am I doing wrong?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire