时间:2021-07-01 10:21:17 帮助过:19人阅读
建议把表结构贴出来以供分析
你数据表的结构最好发一下,因为都不知道你的数据表帖子的时间字段是什么格式的
现举最简单的表结构如下: 如提所问,php mysql 语句该如何书写?
select count(id) from table where datetime=curdate()-1 昨天
select count(id) from table where datetime=curdate() 今天
select date_format(tb_send_date, '%Y-%m-%d') as date, count(*) as cnt from tbl_name group by to_days(tb_send_date) order by desc limit 2
$today_rows="select count(*) from table where tb_send_date>='".date('Y-m-d 00:00:00')."' and tb_send_date<='".date('Y-m-d 23:59:59')."'";//今天$tomorrow=date("Y-m-d",strtotime("-1 day")); $tomorrow_rows="select count(*) from table where tb_send_date>='".$tomorrow." 00:00:00' and tb_send_date<='".$tomorrow." 23:59:59'";;//昨天
$today_rows="select count(*) from table where tb_send_date>='".date('Y-m-d 00:00:00')."' and tb_send_date<='".date('Y-m-d 23:59:59')."'";//今天$tomorrow=date("Y-m-d",strtotime("-1 day")); $tomorrow_rows="select count(*) from table where tb_send_date>='".$tomorrow." 00:00:00' and tb_send_date<='".$tomorrow." 23:59:59'";;//昨天
今天
select count(*) from table where date_format(tb_send_date,"%Y-%m-%d")=curdate()
昨天
select count(*) from table where date_format(tb_send_date,"%Y-%m-%d")=DATE_SUB(curdate(),INTERVAL 1 DAY)
$today_rows="select count(*) from table where tb_send_date>='".date('Y-m-d 00:00:00')."' and tb_send_date<='".date('Y-m-d 23:59:59')."'";//今天$tomorrow=date("Y-m-d",strtotime("-1 day")); $tomorrow_rows="select count(*) from table where tb_send_date>='".$tomorrow." 00:00:00' and tb_send_date<='".$tomorrow." 23:59:59'";;//昨天
$today_rows="select count(*) from table where tb_send_date>='".date('Y-m-d 00:00:00')."' and tb_send_date<='".date('Y-m-d 23:59:59')."'";//今天$tomorrow=date("Y-m-d",strtotime("-1 day")); $tomorrow_rows="select count(*) from table where tb_send_date>='".$tomorrow." 00:00:00' and tb_send_date<='".$tomorrow." 23:59:59'";;//昨天
$today_rows="select count(*) from table where tb_send_date>='".date('Y-m-d 00:00:00')."' and tb_send_date<='".date('Y-m-d 23:59:59')."'";//今天$tomorrow=date("Y-m-d",strtotime("-1 day")); $tomorrow_rows="select count(*) from table where tb_send_date>='".$tomorrow." 00:00:00' and tb_send_date<='".$tomorrow." 23:59:59'";;//昨天