Write sql query to remove the duplicate record from a table.

preetha s
preetha s

Posted On: Dec 17, 2020

 

SQL query to remove the duplicate record from a table is as follows:

DELETE FROM Table_name 
WHERE 
fieldname1 NOT IN 
( 
SELECT 
MAX(fieldname1) 
FROM 
Table_name
GROUP BY 
FieldName2, FieldName2 
);

You can also find the distinct values from the tables by using the following query: Select distinct columnName from Table_name;

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    HCL freshers interview questions

    What is an array?

    In programming, Array is a collection of similar types of values in a single unit. Array stores data in a contiguous memory location....

    HCL freshers interview questions

    Explain ISO/OSI Model and it's Layers?

    The OSI model is a networking model for understanding and designing a network architecture that would be flexible, robust, and interoperable. Communication between different systems without requiring ...

    HCL freshers interview questions

    What are four pillars of OOPS?

    The four pillars of OOPs are as follows:Inheritance Abstraction Encapsulation Polymorphism ...