2017-06-15 13 views
2

に私が書かれていません生のクエリは、phpMyAdminの上で動作しますが、laravel

Laravelで
SELECT customers.customer_name, customers.voucher_number , 
     services.name, customers.status,sum(carts.amount) FROM services JOIN customers 
     on services.id = customers.service_id JOIN carts on customers.id = carts.customer_id   
     GROUP BY customers.id 

$status_report = DB::select("SELECT customers.customer_name, customers.voucher_number , 
     services.name, customers.status,sum(carts.amount) FROM services JOIN customers 
     on services.id = customers.service_id JOIN carts on customers.id = carts.customer_id   
     GROUP BY customers.id"); 

何の可能なエラーをだろうか?あなたの生のSQLをラップするDB::rawを使用する必要が

SQLSTATE[42000]: Syntax error or access violation: 1055 'maitree.customers.customer_name' isn't in GROUP BY (SQL: SELECT customers.customer_name, customers.voucher_number , 
services.name, customers.status,sum(carts.amount) FROM services JOIN customers 
on services.id = customers.service_id JOIN carts on customers.id = carts.customer_id 
GROUP BY services.id) 

答えて

0

は、私は次のエラーを得ました。

$status_report = DB::select(DB::raw("SELECT customers.customer_name, customers.voucher_number , 
    services.name, customers.status,sum(carts.amount) FROM services JOIN customers 
    on services.id = customers.service_id JOIN carts on customers.id = carts.customer_id   
    GROUP BY customers.id")); 
+0

DB :: rawも使用しましたが、出力が得られませんでした。 – Hola

0

それはSQL_MODEであるかもしれない、 "設定/ database.phpでの" 接続への変更を行います:

strict => false

ホープこれはあなたを助けるでしょう。

関連する問題