I have tables set up like so:
Parent ------ id, ... Child ----- id, parent_id, x, y
I want to find the Parents, or the distinct parent_id(s),
Should join 2 tables first because the parents does not have children that will satisfy
And should add index for pa_id column
SELECT DISTINCT pa.id FROM pa INNER JOIN c ON c.pa_id = pa.id WHERE NOT EXISTS ( SELECT 1 FROM c WHERE c.parent_Id = p.id and c.x <> c.y )