简体   繁体   English

MySQL-计算结果并以降序显示

[英]Mysql - count results and display in descending order

I want to query the table to get every referer and count duplicates and display each unique referrer and the number of times each unique referrer is recorded in the table. 我想查询表以获取每个referer并计算重复项,并显示每个唯一引用人以及每个唯一引用人在表中记录的次数。 I'm a beginner with sql and php so any help in the right direction would be great :) 我是sql和php的初学者,所以在正确方向上的任何帮助都将很棒:)

$ref=$icdb->get_row("SELECT * FROM url_log WHERE u = '".$dom."'");

I recommend you run & customise the query in a mysql tool like phpMyAdmin , or HeidiSQL (great freeware tools) to see the results it gives. 我建议您在phpMyAdminHeidiSQL (大型免费软件工具)等mysql工具中运行和自定义查询,以查看查询结果。

It's difficult to give a precise answer without knowing what fields are in your table, but you could try; 不知道表中的字段很难给出准确的答案,但是您可以尝试;

SELECT u, COUNT(*) AS c FROM url_log GROUP BY u

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

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