I’m creating a DB with “Team” table for some NFL teams, and I have assigned them all a ranking (standing in NFL), the attribute is called “Ranking”.
I want to create a trigger such that if the ranking is updated, all of the others are updated appropriately.
However, I can’t figure out a way to loop through the table. For example, assume team at rank 5 moves up to rank 3, how do I get the rank 3 to become 4, and then 4 to be 5?
If you need more info, feel free to ask, I’ll provide it ASAP.
If you know the id of the team to update (lets call it 42) and the old and new rank (old: 5, new: 3), then it’s not too hard: