I just found an elegant query to identify duplicate entries in a
table.  It is from Microsoft.

http://support.microsoft.com/kb/139444

Here's the information:

create table t1(col1 int, col2 int, col3 char(50))
insert into t1 values (1, 1, 'data value one')
insert into t1 values (1, 1, 'data value one')
insert into t1 values (1, 2, 'data value two')

The first step is to identify which rows have duplicate primary key (my
table has no primary keys, but it still works) values:

SELECT col1, col2, count(*)
FROM t1
GROUP BY col1, col2
HAVING count(*) > 1

This query results in:
col1    col2    count(*)
1       1       2

Isn't this just too cool!?
-- 
__________________________________________________________________
3.14159265358979323846264338327950      Let the spirit of pi
2884197169399375105820974944592307   spread all over the world!
8164062862089986280348253421170679 http://pi314.at  PI VOBISCUM!
==================================================================
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to