Basically I have a genealogy table where everybody has a child_id for themselves and a parent_id (both of which are fields in my table). My goal is to add + 1 to my vote field to each parent in a lineage.
So, I need to SELECT the parent_id from a row and update the vote. Then I need to select the parent from that row and update that parents vote. Then i need to select the parent from THAT row and do the same thing..over and over until I get to the very first ancestor and there are no more parents or children to update. Here are my select and update queries:
SELECT parent_id FROM profiles where child_id = $first_ancestor
UPDATE profiles SET votes = votes + 1 where child_id = parent_id
Do I use a loop? Or how do I do this? Thanks!