我需要总结总计列的结果: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 回答
哆啦的时光机
TA贡献1779条经验 获得超6个赞
删除GROUP BY:
SELECT SUM(number_guest) AS total
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');
- 1 回答
- 0 关注
- 116 浏览
添加回答
举报
0/150
提交
取消