How to remove duplicate data in SQL
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.