I have a table called "topay_list" and it contains a field called "user_id". I need to know the number of UNIQUE user_id in the table.
the count(user_id) gives me all the user_id's including repeating ones. How can I use the below statement in conjunction with "distinct"?
$sql2="select Count(user_id) from topay_list where sb_club='$i2[0]'";
thank you
$sql = "select distinct user_id from topay_list where sb_club='$i2[0]'";
$rows = mysql_query($sql);
$numrows = mysql_num_rows [php.net]($rows);
SELECT DISTICT user_id, COUNT(user_id) AS sum FROM topay_list WHERE sb_club='$i2[0]' GROUP BY user_id ORDER BY sum;
...which will return lines containing the user_id and the times it occurs in the table (just a warning, if the table is big this can take time to execute)