I am trying to construct an SQL query that would take a set of rows and renumber a field on all rows, starting at where they all match a session ID.
e.g. before change:
SessionID  |  LineNumber  |  LineContents
----------------------------------------------
74666      |  1           | example content
74666      |  2           | some other content
74666      |  3           | another line
74666      |  4           | final line
after change (user has deleted line 2 so the 'LineNumber' values have updated to reflect the new numbering (i.e. line '3' has now become line '2' etc.):
SessionID  |  LineNumber  |  LineContents
----------------------------------------------
74666      |  1           | example content
74666      |  2           | another line
74666      |  3           | final line
So reflecting this in NON proper syntax would be something along these lines
i = 0;
UPDATE tbl_name
SET LineNumber = i++;
WHERE SessionID = 74666;
Searches a lot for this with no luck, any help is great :)
 
     
     
     
     
     
     
    