主要是原始查询:
DB::table('item_details')->selectRaw('GROUP_CONCAt(...) INTO @sql')->get();DB::statement('SET @sql = CONCAt(...)');DB::statement('PREPARE stmt FROM @sql');DB::statement('EXECUTE stmt');DB::statement('DEALLOCATE PREPARE stmt');
尝试这个:
DB::table('item_details')->selectRaw('GROUP_CONCAt(...) INTO @sql')->get();$sql = DB::selectOne('select @sql')->{'@sql'};ItemDetails::select('item_number', DB::raw('SUM(quantity) as total_quantity')) ->selectRaw($sql) ->groupBy('item_number') ->get();
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)