0
我的SQL查詢顯示在phpMyAdmin正確的,但是當我在laravel 5.4項目中使用它,它會顯示錯誤MySQL查詢加盟,算上
SQLSTATE [42000]:語法錯誤或訪問衝突:1055 'project_management.addprojects.id'不在GROUP BY中(SQL:SELECT DISTINCT addprojects.id,addprojects.emp_id,sum(tasks.task_weight),來自addprojects的tasks.flag JOIN任務ON任務.proj_id = addprojects.id GROUP BY tasks.proj_id)
DB::select(" SELECT DISTINCT addprojects.proj_name,addprojects.id,
addprojects.emp_id,sum(tasks.task_weight),tasks.flag from addprojects
JOIN tasks ON tasks.proj_id = addprojects.id GROUP BY tasks.proj_id ");
它顯示「未定義的屬性:stdClass :: $ task_weight」 –
查詢有問題。爲什麼不使用雄辯,寫原始的sql總是耗時 – devsourav
[https://laravel.com/docs/5.5/queries#raw-expressions]可能會幫助你,如果你不使用Eloquent – devsourav