I want to implement SO like tags on userpost. I have a table called tag_data with columns tagId, title, count. I have a separate table that links the relationship between a post and the many tags it may use.
Heres the problem, how do i get the current count, increase or decrease it by one and store it SAFELY. So no other connection/thread will update it between the time i do select and update?
I assume you also want the new count, other wise this is a no brainer, just update set count=count+1.
If your db support output clause on UPDATE (eg. SQL Server 2K5 or 2K8):
otherwise: