From https://www.percona.com/blog/2019/05/13/solve-query-failures-regarding-only_full_group_by-sql-mode/
“Hey, what’s going on with my applications? I installed a newer version of MySQL. I have queries that perfectly run with the older version and now I have a lot of errors.”
This is a question some customers have asked me after upgrading MySQL. In this article, we’ll see what one of the most frequent causes of this issue is, and how to solve it.
We are talking about this error:
My error is the same:
In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'ebenlizy_inventorycontrol.sales_orders.orderId'; this is incompatible with sql_mode=only_full_group_by
my query is
$query=mysqli_query($conn,"
SELECT
Sum(sales_order_details.quantity) AS Quantity,
(SELECT buyingPrice from items INNER JOIN sales_order_details ON items.stockId = sales_order_details.stockId WHERE sales_order_details.orderId = sales_orders.orderId) AS buyingPrice,
sales_order_details.price
FROM sales_orders
JOIN sales_order_details ON sales_orders.orderId = sales_order_details.orderId
WHERE MONTH(sales_orders.orderDate)='$month'
and YEAR(sales_orders.orderDate)='$year'
AND sales_orders.branchId =$id
AND salesStatus=1")
or die(mysqli_error($conn));