1.

How to find duplicate records in a table?

Answer»

The DISTINCT statement or GROUP BY statement can be USED to identify duplicate records in a table. 

SELECT DISTINCT column 1, column 2... FROM TABLENAME;

OR  

SELECT column 1, column 2,... FROM tablename GROUP BY column 1, column 2....;

Example: CONSIDER the FOLLOWING student table.

Roll_NoFirst_NameLast_Name
101AshaBisht
102RahulPatidar
103VishalBairagi
104GirjaShankar
105AshaDange

DISTINCT

Here is an example of a DISTINCT statement.

SELECT DISTINCT First_Name FROM tablename;

Output: Following is the output of the above query when executed. With a distinct statement, duplicate values can be eliminated.

First_Name
Asha
Rahul
Vishal
Girja


Discussion

No Comment Found