Click here to Skip to main content
Rate this: bad
good
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 9:33am
tram7440
Edited 1-Jun-11 9: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 at 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
0 DamithSL 320
1 OriginalGriff 155
2 Peter Leow 115
3 Afzaal Ahmad Zeeshan 114
4 deepakdynamite 110
0 OriginalGriff 7,510
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 5,044
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 2 Jun 2011
Copyright © CodeProject, 1999-2014
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