Re:User-defined Order in SQL
by speleding on Wednesday March 21, 2018 @06:47AM
(#16636899)
I agree, but I use a small improvement to the first approach: split each insert into two steps: "insert at end" and "reorder".
That way:
(a) the insert is nice and simple and
(b) you can reuse the code for re-order which you likely need anyway (and which solves the foreign key constraint issue, perhaps by doing it in a single SQL update).
[ Parent
| on HN ]