[英]Count number of rows in database between two time stamps
In my database I'm using the current time stamp based on the customer orders, stored in a table.在我的数据库中,我使用基于客户订单的当前时间戳,存储在表中。 I want to know, within two time periods, how many customers order a request.我想知道,在两个时间段内,有多少客户订购了一个请求。 Suppose 10:12:16
to 13:32:54
, in this time period how many(count) customers requested?假设10:12:16
到13:32:54
,在这个时间段内有多少(计数)客户请求? In the same way as in between 2 dates.与两个日期之间的方式相同。
SELECT * FROM your_table WHERE time_stamp_column BETWEEN '10:12:16' AND '13:32:54';
The Simple My SQL Query is this :简单的我的 SQL 查询是这样的:
SELECT COUNT(*) FROM your_table WHERE time_stamp_column BETWEEN '10:12:16' AND '13:32:54';
Using Codeigniter's Query Builder you can do this :使用 Codeigniter 的查询生成器,您可以执行以下操作:
public function getCount(){
return $this->db->get_where('your_table','time_stamp_column BETWEEN "10:12:16" AND "13:32:54"')->num_rows();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.