Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Find duplicate data

Author  Topic 

Topaz
Posting Yak Master

199 Posts

Posted - 2008-10-02 : 11:32:25
Im wanting to find duplicate websites in my DB but have no idea how to do so.

select * from table_name where (duplicates)

Thats a poor effort but any ideas?

JT

wormz666
Posting Yak Master

110 Posts

Posted - 2008-10-02 : 11:45:35
try this

Select *,dd from tbl_name temp1
inner join (Select count(field_name),field_name as dd from tbl_name group by field_name) temp2
on temp1.field=temp2.field
where dd > 1
Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2008-10-02 : 11:49:43
I get this error...

Incorrect syntax near the keyword 'on'.


JT
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-02 : 12:11:48
[code]SELECT *
FROM table_name t
JOIN
(SELECT website
FROM table_name
GROUP BY website
HAVING COUNT(*) >1)tmp
ON tmp.website=t.website[/code]
Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2008-10-02 : 12:21:19
Interesting result...

Is there any way i can simply select website from my table. I tried this:

SELECT website
FROM table_name t
JOIN
(SELECT website
FROM table_name
GROUP BY website
HAVING COUNT(*) >1)tmp
ON tmp.website=t.website


To confirm all that is happening here the DB is finding duplicate websites?

JT
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-03 : 04:07:58
quote:
Originally posted by Topaz

Interesting result...

Is there any way i can simply select website from my table. I tried this:

SELECT website
FROM table_name t
JOIN
(SELECT website
FROM table_name
GROUP BY website
HAVING COUNT(*) >1)tmp
ON tmp.website=t.website


To confirm all that is happening here the DB is finding duplicate websites?

JT


first run this

SELECT website
FROM table_name
GROUP BY website
HAVING COUNT(*) >1


and see if it return only duplicately existing websites
Go to Top of Page
   

- Advertisement -