Mysql count counts deduplicated data

Without deduplication, it is 4:

 

SELECT COUNT(NAME) FROM test2

Obviously it contains 2 data whose name is equal to mike, so duplication needs to be removed:

By combining the count function and the DISTINCT keyword

SELECT COUNT(DISTINCT  NAME) FROM test2

Okay, that’s it.

Guess you like

Origin blog.csdn.net/qq_35387940/article/details/135377569