The use of mysql distinct By The Way, mysql's DISTINCT keyword has a lot you can't think of. 1. when count does not repeat, it can be used, for example, select count (DISTINCT id) FROM tablename; it is used to calculate the number of records with different IDs in the talbebname table, you can use select distinct id FROM tablename to return the specific values of different IDs in the talbebname table. in case 2 above, there will be ambiguity when you need to return results with more than two columns in the mysql table, such as select distinct id and type FROM tablename; in fact, the returned results are results with different IDs and types, that is, DISTINCT applies to two fields at the same time, so that the id and tyoe must be the same to be excluded. This is different from the expected result 4. at this time, you can consider using the group_concat function for troubleshooting, but this mysql function is supported above mysql4.1. another solution is to use SELECT id, type, count (DISTINCT id) FROM tablename although this returned result contains a column of useless count data (maybe you need this useless data I mentioned) the returned result is that only the results with different IDS can be used in concert with the above four types. It depends on what data you need.