Click here to Skip to main content
15,885,912 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi All..
I have Table Like This
Collapse

sno  name  regno
1    Jhon  3201
2    mark  3203
3    bell  3205
4    bean  3206


When I update sno 1 record regno to 2101 remaining all records Should be Like this
Collapse

sno name  regno
1   Jhon  2101 
2   mark  2102
3   bell  2103 
4   bean  2104


i Tried In This Way According To OriginalGriff Suggestion
SQL
delimiter |
CREATE TRIGGER testref BEFORE UPDATE ON test1
  FOR EACH ROW BEGIN
   UPDATE test1 SET regno = regno + 1 WHERE regno > NEW.regno;
  END;
|
delimiter ;

If i Do UPDATE like
SQL
update test1 set regno='2101' where sno='1' 

Then I Get Result Like
sno name  regno
1   Jhon  2101 
2   mark  2102
3   bell  2102 
4   bean  2102

But I Need To Get Table Like
sno name  regno
1   Jhon  2101 
2   mark  2102
3   bell  2103 
4   bean  2104

Am Out Of ideas Can Any One Help Me Please
Thanks In Advance
Posted
Updated 1-Jun-11 8:45am
v3

1 solution

for this you will have to set trigger to recursive following link may be helpful for that http://bugs.mysql.com/bug.php?id=25489[^]
 
Share this answer
 
Comments
tram7 2-Jun-11 11:49am    
thanks for reply There Is no such information i did't get anything

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900