我正在嘗試獲取 Laravel select 語句中返回的記錄總和,但我似乎無法正確獲取。我的原話如下;$results = DB::table('polls')->select('polls.id as poll_id', 'poll_votes.vote_count as vote_count', 'poll_options.id as poll_option_id') ->join('poll_options','polls.id','=','poll_options.poll_id') ->join('poll_votes', 'poll_options.id', '=', 'poll_votes.poll_option_id') ->where([['polls.status','=','1'], ['poll_options.status','=','1'],]) ->get();我嘗試在該->select行的最后一個(gè)元素之后添加以下內(nèi)容,但我不斷收到錯(cuò)誤消息;DB::raw('sum(poll_votes.vote_count) total_votes')任何幫助將不勝感激
- 2 回答
- 0 關(guān)注
- 184 瀏覽
添加回答
舉報(bào)
0/150
提交
取消