I have a Laravel query that works when our DB is using our MySQL DB, but when I switch to our new PostgreSQL DB it stops working.
I am using Laravel's group by function as below:
$this->crud->groupBy('leads.id')
The whole query translated to mysql is below:
select count(*) as aggregate
from (select leads.* from leads
where leads.club_id in ('TR71') and
leads.deleted_at is null GROUP BY leads.id) as aggregate_table;
The error that is now giving is the following:
"SQLSTATE[42803]: Grouping error: 7 ERROR: column \"leads.name\" must appear in the GROUP BY clause or be used in an aggregate function (SQL: select count(*) as aggregate from (select \"leads\".* from \"leads\" where \"leads\".\"club_id\" in (TR71) and \"leads\".\"deleted_at\" is null group by \"leads\".\"id\") as \"aggregate_table\")"
It pretty much is asking me to list each column from the leads.* part of the query into the group by clause. So far I have tried listing each column but it is not efficient or good practice as we could always end up in the situation where we add more columns to the table