Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to remove duplicate data in SQL

Shulou Source: shulou.com Published: 2022-06-01 16:07:01 10月01日 Update

What this article shares with you is about how to remove duplicate data in SQL. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

The distinct keyword can be used to remove the exact same data in SQL, and group by can be used to remove duplicates in any field. Take the following data table as an example.

Idnamescore1 Xiao Wang 512 Xiao Wei 613 Xiao Zhang 714 Xiao Li 515 Xiao Wang 51

1. There are two identical records, which can be removed by using the keyword distinct

Select distinct * from tblidnamescore1 Xiao Wang 512 Xiao Wei 613 Xiao Zhang 714 Xiao Li 51

Only the fields with identical name and score fields are removed from the above.

two。 Field deduplication, using group by, there must be a unique id

Select * from tbl where id in (select max (id) from tbl group by score) idnamescore1 Wang 512 Xiao Wei 613 Xiao Zhang 71 is how to remove duplicate data in SQL. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Data field Xiao Wang same Xiao Zhang Xiao Wei key keyword more knowledge article Xiao Li practical two that is work meeting data sheet article look knowledge point Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MariaDB Shulou Information Redmi Xiaomi