Does mysql deduplicate a field and display other field information? Recently, it was required that the deduplication function be performed based on the values of a column in the SQL statement, and information about other fields should be displayed. selectdistinctname and sorcefromtable are used, and the result shows that deduplication does not work, because MYSQL considers that sorce and name must be repeated at the same time to be removed .??? Google, repeated
Does mysql deduplicate a field and display other field information? Recently, a requirement is to deduplicate data based on the values of a column in the SQL statement and display the information of other fields. select distinct name and sorce from table are used. The result shows that deduplication does not work, because MYSQL considers that sorce and name must be repeated at the same time to be removed. ??? Google, repeated
Mysql removes duplicates based on a field and displays information about other fields.
?
Recently, one requirement is to remove duplicates based on a column value in the SQL statement and display information about other fields,
Using select distinct name, sorce from table, we found that deduplication does not work, because MYSQL considers that sorce and name must be repeated at the same time before removal.
??? Google, the final solution for repeated tests is as follows:
??? Select *, count (distinct name) from table group by name
??? If the SQL statement has conditions such as limit and order by, it must be placed behind group.
This achieves the goal of both removing duplicates and outputting more field information.
Record, with a memo, to help you.