PHP 数据库操作,怎么以日期取出每天出现的不同ip数量。
我有张表,如下图,我想以datetime排序,获得每天出现过几个ip地址。
我用下面这段的话,只能取出总数,不是个数
$data['num_ip'] = Db::name("visitors")->where($where)->field("count(ip) as count,datetime")->group("datetime")->select();
,
这得嵌套查询了吧,第一层按日期,IP去重,第二层再像你现在这样
select count(ip) as count,datetime from(
select ip,datetime from table_name group by ip,datetime
)as a
group by datetime
回答
以上是 PHP 数据库操作,怎么以日期取出每天出现的不同ip数量。 的全部内容, 来源链接: utcz.com/a/112282.html