A Simple Autistic SQL trick

Ever had that sickening feeling that after a Database efficiency cleanup, your ID's are no longer in line with the actual amount of records?
Congratulations, you have autistic tendencies! (We have a club)

Set @a = 0;  
update tablename set id=@a:=@a+1 order by id asc;  

The above will give you a warm and soothing feeling inside.

comments powered by Disqus