sql - Find duplicates for several columns exclusive ID-column -


i've found lot of answers on how find duplicates including pk-column or without focus on this:

if have table called t1, , columns c1, c2 , c3 query show duplicate values.

select c1, c2, c3, count(*)as dupcount  t1  group c1, c2, c3  having count(*) > 1 

but more common requirement id of duplicates have equal c1,c2,c3 values.

so need following doesn't work because id must aggregated:

select id  t1  group c1, c2, c3  having count(*) <> 1 

(the id of duplicates must different columns must equal)

edit:

thank all. i'm suprised how fast people give excellent answers on stackoverflow!

there lot of versions suggested here think came new one.

select * @t t1 exists (select *               @t t2                               t1.id <> t2.id ,                 t1.c1 = t2.c1 ,                 t1.c2 = t2.c2 ,                 t1.c3 = t2.c3) 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -