Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用两列查找mysql数据库中流行的域_Php_Mysql - Fatal编程技术网

Php 使用两列查找mysql数据库中流行的域

Php 使用两列查找mysql数据库中流行的域,php,mysql,Php,Mysql,我一直在寻找这个问题的解决方案,但还没有找到一个有效的答案 我有一个MySql表,如下所示: URL Domain Clicks http://www.example1.com/erte.html example1.com 10 http://www.example2.com/xndd.html example2.com 5 http://www.example3.com/4567.

我一直在寻找这个问题的解决方案,但还没有找到一个有效的答案

我有一个MySql表,如下所示:

URL                                   Domain          Clicks
http://www.example1.com/erte.html     example1.com    10
http://www.example2.com/xndd.html     example2.com    5
http://www.example3.com/4567.html     example3.com    4
http://www.example1.com/bcdv.html     example1.com    7
http://www.example1.com/098i.html     example1.com    17
它显示URL、URL指向的域以及为每个URL记录的单击次数

我希望能够显示最流行的域,使用我通过添加该域的总点击次数得到的值,而不管它是哪个实际URL

因此,根据我的样本值:

example1.com = 34
example2.com = 5
example3.com = 4
到目前为止,我能找到的示例显示了如何根据一个项目在数据库中显示的次数来查找该项目的受欢迎程度。然而,这并不像我想做的那样包括“点击”栏

以下是我迄今为止发现的例子:

example1.com = 3
example2.com = 1
example3.com = 1
这不是我真正想要的

我不知道如何有效地完成这项工作,如果能得到任何帮助,我将不胜感激。

试试:

select domain, sum(clicks) as "total_count" from TABLE group by domain order by total_count asc

这将为您提供从最低到最高的排序总数(点击次数)

如果您也发布了您的查询,这将很有帮助。我没有一个用于确定受欢迎程度的查询,这正是我正在尝试解决的问题。我现在尝试一下,让您知道它是如何进行的。