简体   繁体   English

计算表中唯一数据的数量

[英]Count the number of unique data in a table

I have a table in a database that stores the name of each User who accessed my application in PHP. 我在数据库中有一个表,其中存储了使用PHP访问我的应用程序的每个用户的名称。 I would like to make a function that calculates the number of unique users who accessed it so far (assuming a User can access it more than once). 我想创建一个函数来计算到目前为止访问它的唯一用户数(假设一个用户可以多次访问它)。 However, I have no idea how to make this count . 但是,我不知道该如何计算。

要计算唯一身份用户的数量,您可以

SELECT COUNT(DISTINCT `column_name`) FROM `table_name`

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

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