Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
SQL DELETE DUPLICATE ROWS

SQL DELETE DUPLICATE ROWS

Posted on March 13, 2025March 13, 2025 By Rishabh saini No Comments on SQL DELETE DUPLICATE ROWS

SQL DELETE DUPLICATE ROWS

When dealing with large datasets, it’s common to encounter duplicate records in a table. Duplicate data can cause inaccurate record fetching results if it is not managed appropriately. To ensure accuracy, we must retrieve unique records instead of duplicates.

To solve this issue, SQL provides the DISTINCT keyword, which is used with the SELECT statement to eliminate duplicate records and fetch only unique ones.

Complete Python Course with Advance topics:-Click Here
SQL Tutorial :-Click Here

Using DISTINCT to Remove Duplicates

The DISTINCT keyword helps retrieve unique values from a specific column or a combination of columns. Below is the syntax:

SELECT DISTINCT column1, column2, ....columnN  
FROM table_name  
WHERE [conditions];  

Example

Let’s consider a EMPLOYEE table with duplicate salary records.

EMP_IDNAMESALARYCITY
101RAHUL VERMA50000MUMBAI
102NEHA SINGH48000DELHI
103ARJUN SHARMA50000BANGALORE
104SAKSHI JAIN52000KOLKATA
105ROHAN MEHTA48000PUNE
106KRITI AGGARWAL51000CHENNAI

Checking for Duplicate Salary Records

Before applying DISTINCT, let’s retrieve all salary records to check for duplicates:

SELECT SALARY FROM EMPLOYEE  
ORDER BY SALARY;  

Output:

SALARY
48000
48000
50000
50000
51000
52000

Using DISTINCT to Remove Duplicates

Now, we apply the DISTINCT keyword to fetch unique salary records:

SELECT DISTINCT SALARY FROM EMPLOYEE  
ORDER BY SALARY;  

Output:

SALARY
48000
50000
51000
52000

Duplicate salary values have been removed, as can be seen above.

Download New Real Time Projects :-Click here
Complete Advance AI topics:- CLICK HERE

Conclusion

In order to preserve data integrity, SQL must handle duplicate records. The DISTINCT keyword is a simple yet powerful solution to fetch unique records from a table, ensuring accurate and meaningful data retrieval.

For more SQL tutorials and updates, stay tuned to UpdateGadh!


sql delete duplicate rows keep one
delete duplicate rows in sql w3schools
to remove duplicate rows in sql select statement
sql delete duplicate rows with same id
sql delete duplicate rows but keep one without primary key
sql delete duplicate rows based on one column
delete duplicate rows in oracle
delete duplicate records in sql server using row_number
sql delete duplicate rows but keep one
cte sql
sql delete duplicate rows oracle

Post Views: 544
SQL Tutorial Tags:all, common table expression, database, delete, delete duplicate records in sql server, delete duplicate rows, delete duplicate rows in sql, delete rows sql, duplicate, eliminate, except one, how to, how to delete all the duplicate records, how to delete all the records but keep one record, how to find the duplicate records from sql table, remove, rows, sql, sql delete duplicates, sql queries, sql remove duplicate rows, sql remove duplicates, sql server, table

Post navigation

Previous Post: SQL DELETE ROW: How to Remove Records from a Table
Next Post: SQL DELETE DATABASE – A Complete Guide

More Related Articles

SQL RENAME TABLE SQL RENAME TABLE: A Complete Guide SQL Tutorial
SQL OR Condition in SQL Queries SQL OR Condition in SQL Queries SQL Tutorial
SQL UPDATE DATE SQL UPDATE DATE: How to Update a Date and Time Field in SQL? SQL Tutorial

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may also like

  1. Understanding the SQL DELETE Statement and Its Variants
  2. SQL Temporary Tables: A Handy Tool for Developers
  3. SQL SELECT TOP Clause: A Comprehensive Guide
  4. SQL ORDER BY LIMIT – Retrieve Specific Rows from a Database
  5. Understanding SQL CROSS JOIN with Examples
  6. IN vs EXISTS in SQL: A Complete Guide

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. Flipkart Clone using PHP And MYSQL Free Source Code
  5. News Portal Project in PHP and MySql Free Source Code
  6. User Login & Registration System Using PHP and MySQL Free Code
  7. Top 10 Final Year Project Ideas in Python
  8. Online Bike Rental Management System Using PHP and MySQL
  9. E learning Website in php with Free source code
  10. E-Commerce Website Project in Java Servlets (JSP)
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Online Examination System in PHP with Source Code
  • AI Chatbot for College and Hospital
  • Job Portal Web Application in PHP MySQL
  • Online Tutorial Portal Site in PHP MySQL — Full Project with Source Code
  • Online Job Portal System in JSP Servlet MySQL

Most Viewed Posts

  • Top Large Language Models in 2025 (8,612)
  • Online Shopping System using PHP, MySQL with Free Source Code (5,209)
  • login form in php and mysql , Step-by-Step with Free Source Code (4,861)

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme