![](/img/trans.png)
[英]Search mysqli for multiple values in one column, return matching another, sort by count of occurrences?
[英]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.