Simply put, distinct is used to remove duplicates, while group by is designed to aggregate statistics. The two have some similarities in the functions they can achieve, but they should be carefully distinguished. The simple deduplication operation using DISTINCT is faster than GROUP BY. distinct supports single-column and multi-column deduplication. The frequency of group by is relatively high, but just like its function, its purpose is to perform aggregate statistics. Although it is also possible to achieve the function of deduplication, this is not its strong point. the difference: 1) distinct simply removes duplicate rows from the result; Group by means grouping by specified columns, and generally aggregate functions are used in select at this time. 2) distinct is to display different records. Group by means to sort the records by category before querying. GROUP BY must include an aggregate function in the query results, while DISTINCT does not. This is the end of this article about the difference between distinct and group by in MySQL. For more information about the difference between distinct and group by, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of the this pointing problem in JavaScript
>>: A brief discussion on simulating multi-threaded and multi-process crashes in Linux
Table of contents Typical Cases Appendix: Common ...
1. Create a database 2. Create a table 1. Create ...
I recently used the MySql database when developin...
Table of contents 1. HttpGET 2. HTTP POST WebSock...
Table of contents use Use of EsLint Add a profile...
<body style="scroll:no"> <tabl...
I would like to share the installation and config...
Nginx can generally be used for seven-layer load ...
1. Flex layout .father { display: flex; justify-c...
Occasionally, I need to group select contents. In ...
The automatic scrolling effect of the page can be...
Table of contents Related dependency installation...
Background: Linux server file upload and download...
1. Introduction When filtering unknown or partial...
Preface In the process of using MySQL database, i...