dupe checking 
Author Message
 dupe checking
how could i check  for duplicate entries in a column?


Tue, 24 May 2005 22:49:54 GMT
 dupe checking

SELECT mycolumn
FROM mytable
GROUP BY mycolumn
HAVING COUNT(*) > 1

--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.


Quote:
> how could i check  for duplicate entries in a column?



Tue, 24 May 2005 23:00:03 GMT
 dupe checking
How do I show all duplicates? Like...









Quote:
> SELECT mycolumn
> FROM mytable
> GROUP BY mycolumn
> HAVING COUNT(*) > 1

> --
> Jacco Schalkwijk MCDBA, MCSD, MCSE
> Database Administrator
> Eurostop Ltd.



> > how could i check  for duplicate entries in a column?



Wed, 25 May 2005 00:29:52 GMT
 dupe checking
You can use

SELECT * FROM mytable t
INNER JOIN(
SELECT mycolumn
FROM mytable
GROUP BY mycolumn
HAVING COUNT(*) > 1) as tc
ON t.mycolumn = tc.mycolumn

or if you are just interested in mycolumn and the number:
SELECT mycolumn, COUNT(*)
FROM mytable
GROUP BY mycolumn
HAVING COUNT(*) > 1

--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.


Quote:
> How do I show all duplicates? Like...










> > SELECT mycolumn
> > FROM mytable
> > GROUP BY mycolumn
> > HAVING COUNT(*) > 1

> > --
> > Jacco Schalkwijk MCDBA, MCSD, MCSE
> > Database Administrator
> > Eurostop Ltd.



> > > how could i check  for duplicate entries in a column?



Wed, 25 May 2005 00:49:59 GMT
 dupe checking
Try:

SELECT *
  FROM tbl
 WHERE col IN (SELECT col
                 FROM tbl
                GROUP BY col
               HAVING COUNT(col) > 1)

--
- Anith
(Please respond only to newsgroups)



Wed, 25 May 2005 00:47:34 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. Fastest way to check for dupes

2. Dupe values vs. nulls in join results

3. SQL Query to insert w/out dupes

4. need SP to insert new key to one table and dupes to another

5. Removing Dupes

6. Dupes

7. Faster insert with ignore dupe key

8. Remove all dupes but ...

9. delete dupe records

10. DUPES

11. Finding Similar Dupes in database

12. Dupes


 
Powered by phpBB® Forum Software