Click here to Skip to main content
12,447,096 members (52,115 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: MySQL
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
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
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 1-Jun-11 8:33am
tram7440
Updated 1-Jun-11 8:45am
v3

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160811.3 | Last Updated 2 Jun 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100