Page 1 of 1

need a bit of logic help here

Posted: Thu Jan 20, 2005 6:02 pm
by Burrito
I have some courses that are being taught in a table. This table has 3 fields:

courseid
userid
courseorder

a user can be enrolled in five courses at a time so the courseorder might be like this:

courseid - courseorder
1 - 3
2 - 4
3 - 2
4 - 1
5 - 5

my question is, if I delete two of those courses, say courseid's 2 and 4, how can I reset the course order?

courseid - courseorder
1 - 3
3 - 2
5 - 5

now needs to be:

courseid - courseorder
1 - 2
3 - 1
5 - 3

my wee little pee brain can't figure this one out

Posted: Thu Jan 20, 2005 6:07 pm
by feyd
select them sorted by course order ascending. update them starting from 1, incrementing with each row.