Laravel db with group by和strict false

时间:2017-07-24 08:47:46

标签: mysql laravel-5 group-by

具有以下laravel db查询和数据库配置' strict' =>假

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();

我得到s.projekt' isn't in GROUP BY

mysql服务器版本5.5.5

如果我复制粘贴查询并在控制台中运行正常

在较新的mariadb上工作正常

0 个答案:

没有答案