2
There is a table with 200 records and one of the fields is responsible for indicating the order that these data are shown (0, 1, 2, 3, 4, 5, ...). I need to rearrange this data, take the record from position 167 and put it in position 3, and obviously what was in position 3 will go to position 4, and 4 to position 5, and so on. The problem is that I will have to change the "position" field of the 164 records that had the position modified. Is there any efficient way to do this? Or will I have to loop by changing each record individually? What if more than one record has to be rearranged?
Note: I am working with Python, Postgresql and Django
I haven’t worked with Django for a long time. In this specific case, a pure sql solution is more than plausible. I’ll check here how you do it in Django
– Jefferson Quesado
How is the order determined? What is the key of the table?
– Clodoaldo Neto