I have a table, sort of like this:
ID | Chromosome | Locus | Symbol | Dominance |
===============================================
1 | 10 | 2
One way of doing this is via an exists
clause:
select * from genes g
where exists
(select null from genes g1
where g.locus = g1.locus and g.chromosome = g1.chromosome and g.id <> g1.id)
Alternatively, in MySQL you can get a summary of all matching ids with a single table access, using group_concat
:
select group_concat(id) matching_ids, chromosome, locus
from genes
group by chromosome, locus
having count(*) > 1