The difference of deweighting between distinct and group by in Mysql
To put it simply, distinct is used to remove weight, while group by is designed to aggregate statistics. There are some similarities in the functions that can be achieved, but they should be carefully distinguished.
Simple deduplication operation using distinct, the speed is faster than group by.
Distinct supports single-column and multi-column deduplication.
The way to remove duplicates in a single column is simple and easy to understand, that is, only one of the same values is retained.
The deduplication of multiple columns is based on the specified deduplicated column information, that is, only all the specified column information are the same, it will be considered duplicate information.
Group by is used relatively frequently, but like its function, its purpose is to aggregate statistics, although it is also possible to achieve deduplication, but this is not its strong point.
Difference:
1) distinct simply takes duplicate rows out of the result
Group by is grouped by specified columns, and aggregate functions are usually used in select.
2) distinct shows different records.
Group by first classifies the records by category before querying.
Group by must include an aggregate function in the query results, but distinct does not.
This is the end of this article on the difference between distinct and group by in Mysql. For more information about the difference between distinct and group by, please search the previous articles or continue to browse the relevant articles below. I hope you will support it in the future!