hakimserwa Posted August 18, 2012 Share Posted August 18, 2012 i have this table id name position published description 1 name 1 1 desc1 2 name 2 1 desc2 3 name 3 1 desc3 4 name 4 1 desc4 5 name 5 1 desc5 now what i want is if i delet record 1,2,3 then position 4,5 will auto update to 1,2. hope its understandable Quote Link to comment Share on other sites More sharing options...
Barand Posted August 18, 2012 Share Posted August 18, 2012 I noticed another post of this question in another forum - http://forums.phpfreaks.com/index.php?topic=364068.msg1723842#msg1723842 DON'T double post. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted August 18, 2012 Share Posted August 18, 2012 I'm not sure why you'd want to do this, but.... anyway, this could be work if the id table is auto_increment. Check this out -> http://stackoverflow.com/questions/740358/mysql-reorder-reset-auto-increment-primary-key SET @count = 0; UPDATE `tbl_name` SET `tbl_name`.`id` = @count:= @count + 1; Quote Link to comment Share on other sites More sharing options...
hakimserwa Posted August 18, 2012 Author Share Posted August 18, 2012 thanks will try this Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted August 19, 2012 Share Posted August 19, 2012 thanks will try this It should be worked, i use this Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.