<update id="moveUp" parameterType="int">
UPDATE tableName
SET sort = sort - 1
WHERE sort > #{id}
ORDER BY sort ASC
LIMIT 1
</update>
其中,#{id}为要上移的元素的排序值。
<update id="moveDown" parameterType="int">
UPDATE tableName
SET sort = sort + 1
WHERE sort < #{id}
ORDER BY sort DESC
LIMIT 1
</update>
其中,#{id}为要下移的元素的排序值。
<update id="moveTop" parameterType="int">
UPDATE tableName
SET sort = sort - 1
WHERE sort < #{id}
ORDER BY sort ASC
LIMIT 1
</update>
其中,#{id}为要置顶的元素的排序值。
<update id="moveBottom" parameterType="int">
UPDATE tableName
SET sort = sort + 1
WHERE sort > #{id}
ORDER BY sort DESC
LIMIT 1
</update>
其中,#{id}为要置底的元素的排序值。