我需要总结总计列的结果:
SELECT SUM(number_guest) AS total, booking_time
FROM mt_bookingtable
WHERE
merchant_id IN (SELECT merchant_id
FROM mt_merchant
WHERE merchant_id = 1 )
AND booking_time BETWEEN "12:00" AND "20:00"
AND
date_booking like "2020-06-01"
AND status in ('pending','approved')
GROUP BY booking_time
我试图像这样使用 foreach:
foreach ($res as $item) {
$sum += $item['total'];
return $sum;
}
但我得到了结果null。
哆啦的时光机