lundi 24 juillet 2017

Laravel db issue with group by and strict false

having the following laravel db query and on database config 'strict'=> false

DB::table('supply as s')
            ->select(
                DB::raw('WEEKOFYEAR(zeit_von) as week'), DB::raw('round(count(s.id)/8,2) as slots_count'),
                's.projekt', 'pas.skillset'
            )
            ->leftJoin('p_projects as p', 'p.id', '=', 's.projekt')
            ->leftJoin('accounts_skillset as pas', 'pas.account_id', '=', 's.employee')
            ->where('s.deleted', 0)
            ->whereIn('s.supply_status', [1, 2])
            ->whereRaw(
                DB::raw("(select count(cal_id) from w_cal as c
                    where c.owner=s.employee
                    and deleted=0
                    and date_format(s.time_from, '%d.%m.%y')=date_format(from_unixtime(c.mdatetime), '%d.%m.%y')
                    and c.category='Kr')<1")
            )
            ->whereRaw(DB::raw('year(time_from)='.$year))
            ->groupBy('pas.skillset', 'p.id', DB::raw('WEEKOFYEAR(s.time_from)'))
            ->get();

I get s.projekt' isn't in GROUP BY

mysql server version 5.5.5

on newer mariadb is working fine



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire