繁体   English   中英

MySQLi计算一列相同而另一列不同

[英]MySQLi count where one column is the same and another column is different

我有一个表格,用于将访问者信息存储到某些网站,其布局如下:

ip_address   |   website_ref   |   page_visited  

123.123.12          abc               index.php
123.123.12          abc               anotherpage.php
123.123.12          efg               index.php
987.987.98          abc               index.php

我正在尝试获取脚本来计算具有相同Website_Ref且仅访问了该网站的单个页面的任何IP地址。

在上面的示例中, abc的系统应计为987.987.98而不是123.123.12因为123.123.12访问的页面多于一个页面。

我该如何编码MySQLi查询以仅计算这些结果?

试试这个查询:

select * from table_name group by ip_address, website_ref having count(*) = 1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM