updating table
Posted: Sat May 06, 2006 7:07 am
hi
i hav a table with a field sort, how will my sql statement be if i want to update it with an incrementing number for sort and will copy the sort number if it has the same categoryid.
ex:
index name categoryid sort
1 x1 1003 null
2 x2 1004 null
3 x3 1001 null
4 x5 1003 null
5 x4 1006 null
6 x6 1005 null
7 x7 1004 null
result after update:
index name categoryid sort
1 x1 1003 1
2 x2 1004 2
3 x3 1001 3
4 x5 1003 1
5 x4 1006 4
6 x6 1005 5
7 x7 1004 2
i hav a table with a field sort, how will my sql statement be if i want to update it with an incrementing number for sort and will copy the sort number if it has the same categoryid.
ex:
index name categoryid sort
1 x1 1003 null
2 x2 1004 null
3 x3 1001 null
4 x5 1003 null
5 x4 1006 null
6 x6 1005 null
7 x7 1004 null
result after update:
index name categoryid sort
1 x1 1003 1
2 x2 1004 2
3 x3 1001 3
4 x5 1003 1
5 x4 1006 4
6 x6 1005 5
7 x7 1004 2