【发布时间】:2021-06-24 23:24:55
【问题描述】:
如何在 Laravel 中编写以下原始查询
$result= DB::select('SELECT a.awb_number,a.full_awb_number,a.service_type, b.city AS From_city, c.country_code AS From_country, b.city AS To_city, c.country_code AS To_country, datediff( max(s.created_at), min(s.created_at)) as Aging FROM customer_shippments a LEFT JOIN addresses b ON a.from_address = b.id LEFT JOIN addresses c ON a.to_address = c.id LEFT JOIN statuses s ON s.awb_number = a.awb_number WHERE a.full_awb_number IN ("LA172827289EE", "LA172828854EE", "LA172829894EE") GROUP BY s.awb_number');
return $result;
在执行上述查询时,我收到以下错误
SQLSTATE[42000]: Syntax error or access violation: 1055 'track.a.awb_number' isn't in GROUP BY (SQL: SELECT a.awb_number,a.full_awb_number,a.service_type, b.city AS From_city, c.country_code AS From_country, b.city AS To_city, c.country_code AS To_country, datediff( max(s.created_at), min(s.created_at)) as Aging FROM customer_shippments a LEFT JOIN addresses b ON a.from_address = b.id LEFT JOIN addresses c ON a.to_address = c.id LEFT JOIN statuses s ON s.awb_number = a.awb_number WHERE a.full_awb_number IN ("LA172827289EE", "LA172828854EE", "LA172829894EE") GROUP BY s.awb_number)
【问题讨论】:
-
你使用什么 DBMS?
-
MySQL 数据库管理
标签: php laravel phpmyadmin