Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

whats your table structure? and an example row from it?

0

Here it 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
Last updated 8 years ago.
0

Anyone have any ideas? Blocked by this issue on my project.

0

there are two single quotes in your 'group_songs''

0

That was when I typed it here. This is happening everywhere I use groupBy.

0

I don't have a field to aggregate, though.

0

Can anyone help me with this groupBy problem? Is there an alternate way to select unique columns? Or is there something wrong with my query above?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

jerauf jerauf Joined 16 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.