I am fairly certain that this is something simple, but every example I have tried is failing. I want to query a table like this
ID Part_Type Station_Typ
select id, part_type, station_type
from myTable t1
where exists (select 1 from myTable t2
where t1.part_type = t2.part_type
and t1.station_type = t2.station_type
and t1.id <> t2.id)
I think a self-join will work for you:
SELECT * FROM table t1
INNER JOIN table t2 ON t1.Part_Type = t2.Part_Type
AND t1.Station_Type = t2.Station_Type
AND t1.Id <> t2.Id
You can use the following:
select t1.id, t1.part_type, t1.station_type
from yourtable t1
where exists (select part_type, station_type
from yourtable t2
where t1.part_type = t2.part_type
and t1.station_type = t2.station_type
group by part_type, station_type
having count(id) > 1)
See SQL Fiddle with Demo