Duplicate Column values in a SQL Table
How to Get Values of column having duplicate records in some other column.
Scenario
I have a table having multiple columns, the two named are ID and email, Now i what i want to do is that i want the values of ID's for those Columns having same email address or duplicate email address. Suppose we have the following table named "Table1" having two fields ID and Email and having following Data.
Use the following SQL Query to get ID's having Duplicate Email address
Select ID from Table1 where Name IN (SELECT Name FROM Table1 GROUP BY Name HAVING ( COUNT(Name) > 1 ))
Now this Query will return 1,3,5,7,10,12,4 and 6 from the above table having same Data.
Scenario
I have a table having multiple columns, the two named are ID and email, Now i what i want to do is that i want the values of ID's for those Columns having same email address or duplicate email address. Suppose we have the following table named "Table1" having two fields ID and Email and having following Data.
ID | |
1 | Email1@Email.com |
2 | Email1@Email-2.com |
3 | Email1@Email.com |
4 | Email1HK@Email.com |
5 | Email1@Email.com |
6 | Email1HK@Email.com |
7 | Email1@Email.com |
8 | Email1we@Email.net |
9 | Email1sd@Emailz.com |
10 | Email1@Email.com |
11 | Email1n@Email.com |
12 | Email1@Email.com |
Use the following SQL Query to get ID's having Duplicate Email address
Select ID from Table1 where Name IN (SELECT Name FROM Table1 GROUP BY Name HAVING ( COUNT(Name) > 1 ))
Now this Query will return 1,3,5,7,10,12,4 and 6 from the above table having same Data.
Comments