abort transaction
update $rel_table
set order_n = :swap_order
where rel_id = :rel_id
update $rel_table
set order_n = :order_n
where rel_id = :swap_id
select
$rel_parent_column
from
$rel_table
where
rel_id = :rel_id
select
order_n
from
$rel_table
where
rel_id = :rel_id
select
rel_id, order_n
from
$rel_table
where
$rel_parent_column = :item_id
and
order_n = :order_n - 1
select
rel_id, order_n
from
$rel_table
where
$rel_parent_column = :item_id
and
order_n = :order_n + 1