В этом ответе я предполагаю, что вы хотите сделать это в SQL, а не в C #. Исходя из этого предположения, эти два оператора SQL внутри одной транзакции увеличивают приоритет указанного навыка на 1.
'Set @User to the required user and @Skill to the required skill.
'Decrease the priority of the user's skill above the specified skill.
UPDATE MyTable
SET priority = priority + 1
WHERE user = @User
AND priority = (SELECT priority - 1
FROM MyTable
WHERE user = @User
AND skill = @Skill)
'Increase the specified skill's priority.
UPDATE MyTable
SET priority = priority - 1
WHERE user = @User
AND skill = @Skill
AND priority > 1
Аналогичным образом эти два оператора SQL увеличьте указанный навык до указанного приоритета.
'Set @User to the required user and @Skill to the required skill.
'Set @NewPriority to the new priority.
'Decrease the higher-prioritised skills.
UPDATE MyTable
SET priority = priority + 1
WHERE user = @User
AND priority >= @NewPriority
AND priority < (SELECT priority
FROM MyTable
WHERE user = @User
AND skill = @Skill)
'Set the specified skill's priority as requested.
UPDATE MyTable
SET priority = @NewPriority
WHERE user = @User
AND skill = @Skill
AND priority > 1
И эти три оператора SQL перемещают указанный навык к указанному приоритету.
'Set @User to the required user and @Skill to the required skill.
'Set @NewPriority to the new priority.
'Decrease the higher-prioritised skills to
'handle case where new priority is higher.
UPDATE MyTable
SET priority = priority + 1
WHERE user = @User
AND priority >= @NewPriority
AND priority < (SELECT priority
FROM MyTable
WHERE user = @User
AND skill = @Skill)
'Increase the lower-prioritised skills to
'handle case where new priority is lower.
UPDATE MyTable
SET priority = priority - 1
WHERE user = @User
AND priority <= @NewPriority
AND priority > (SELECT priority
FROM MyTable
WHERE user = @User
AND skill = @Skill)
'Set the specified skill's priority as requested.
UPDATE MyTable
SET priority = @NewPriority
WHERE user = @User
AND skill = @Skill