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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With