# SQL Logic Prob

**URL:** <https://forum.kirupa.com/t/sql-logic-prob/14064>\
**Category:** programming\
**Created:** [February 21, 2003, 3:37pm UTC](https://forum.kirupa.com/t/sql-logic-prob/14064 "2003-02-21T15:37:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dravos](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@Dravos](https://forum.kirupa.com/u/Dravos)\
**Post date:** [February 21, 2003, 3:37pm UTC](https://forum.kirupa.com/t/sql-logic-prob/14064/1 "2003-02-21T15:37:49Z")

</div>

Hello,

I have a field called TopicNum  
in there are values

```php

[1]=Top1
[2]=Top2
[3]=Top3
[4]=Top4
[5]=Top5
[6]=Top6

```

Now i want to move 5 before 1  
so…

```php

[0]=Top5
[1]=Top1
[2]=Top2
[3]=Top3
[4]=Top4
[6]=Top6

```

Now i need to move 1,2,3,4 to 2,3,4,5  
but 1 cant go to 2 cos 2 is still there

i could do sepearte queries and do 4 to 5 then 3 to4 etc but this is lengthy with more records  
is there any way i can do this in one query.

end result should be

```php

[1]=Top5
[2]=Top1
[3]=Top2
[4]=Top3
[5]=Top4
[6]=Top6

```

Thanx
