can u post the table structure?
Aug 12, 2017
12
Level 2
Select All from table and group by specific column
I want to select all the entries in the referrals table and them group by referral
$referrals = Booking::whereNotNull('referral')->groupBy('bookings.referral')->orderBy('referral_income', 'DESC')->get();
This is the error I got
SQLSTATE[42000]: Syntax error or access violation: 1055 'bookings.id' isn't in GROUP BY (SQL: select * from `bookings` where `referral` is not null and `bookings`.`deleted_at` is null group by `bookings`.`referral` order by `referral_income` desc)
Please note that my Referral column has been made an index on the database.
Bookings Table structure
id, room_id, user_id, transaction_id, reference, price, discount_price, referral_income, referral, status
Thank you
Please or to participate in this conversation.