我需要总结总计列的结果:
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
.
1条答案
按热度按时间m1m5dgzv1#
拆下
GROUP BY
: