Deduplication in mysql

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/raoxiaoya/article/details/100534401

About distinct keywords

select DISTINCT uid, name from zzzz;

Which really means is to remove the duplicate records, the first select uid, name from zzzz;and then filter out duplicate records, the first record retention. Therefore, the results dinstinct depends on the field you are looking for, it is not filtered out of a field.

If we only need to filter out duplicate uid it?

select uid, name from zzzz group by uid;

Or filter out duplicate uid, name

select uid, name, age from zzzz group by uid, name;

Guess you like

Origin blog.csdn.net/raoxiaoya/article/details/100534401