create table candidatos (id int auto_increment primary key, sq_candidato int, nome varchar(50));
insert into candidatos values (1, 250010, 'Fulano');
insert into candidatos values (2, 250010, 'Fulano');
insert into candidatos values (3, 250013, 'Beltrano');
insert into candidatos values (4, 250013, 'Beltrano');
insert into candidatos values (5, 250015, 'Sicrano');
-- Tabela atual
select * from candidatos;
-- Linhas a serem removidas (duplicadas)
select candidatos.id from candidatos
inner join candidatos c on c.sq_candidato = candidatos.sq_candidato
where c.id <> candidatos.id
group by candidatos.sq_candidato;
--Removendo as linhas
delete from candidatos where id in(
select candidatos.id from candidatos
inner join candidatos c on c.sq_candidato = candidatos.sq_candidato
where c.id <> candidatos.id
group by candidatos.sq_candidato
);
-- Tabela atualizada
select * from candidatos;
Y3JlYXRlIHRhYmxlIGNhbmRpZGF0b3MgKGlkIGludCBhdXRvX2luY3JlbWVudCBwcmltYXJ5IGtleSwgc3FfY2FuZGlkYXRvIGludCwgbm9tZSB2YXJjaGFyKDUwKSk7Cmluc2VydCBpbnRvIGNhbmRpZGF0b3MgdmFsdWVzICgxLCAyNTAwMTAsICdGdWxhbm8nKTsKaW5zZXJ0IGludG8gY2FuZGlkYXRvcyB2YWx1ZXMgKDIsIDI1MDAxMCwgJ0Z1bGFubycpOwppbnNlcnQgaW50byBjYW5kaWRhdG9zIHZhbHVlcyAoMywgMjUwMDEzLCAnQmVsdHJhbm8nKTsKaW5zZXJ0IGludG8gY2FuZGlkYXRvcyB2YWx1ZXMgKDQsIDI1MDAxMywgJ0JlbHRyYW5vJyk7Cmluc2VydCBpbnRvIGNhbmRpZGF0b3MgdmFsdWVzICg1LCAyNTAwMTUsICdTaWNyYW5vJyk7CgotLSBUYWJlbGEgYXR1YWwKc2VsZWN0ICogZnJvbSBjYW5kaWRhdG9zOwoKLS0gTGluaGFzIGEgc2VyZW0gcmVtb3ZpZGFzIChkdXBsaWNhZGFzKQpzZWxlY3QgY2FuZGlkYXRvcy5pZCBmcm9tIGNhbmRpZGF0b3MKaW5uZXIgam9pbiBj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