Count total without duplicate using MySQL and PHP
10,769
This DISTINCT
in this query:
SELECT COUNT(DISTINCT `column`) AS `cnt` FROM `table`;
will eliminate duplicates.
Then, from php, fetch the cnt
column value the way you would do for any other regular query.
Author by
Jeremy
Updated on June 06, 2022Comments
-
Jeremy almost 2 years
I am attempting to query a MySQL database with PHP to count the total number of entries without duplicates.
EXAMPLE N111US N111US N123US N345US A6-EWD A7-EEE B-18701 N123US N345AA
I wish to have the total number of the unique entries, and I cannot begin to see where to start with the SQL query, that is, Total Returned: 7