Click here to Skip to main content
Sign Up to vote bad
good
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:33
tram7367
Edited 1 Jun '11 - 8:45
JOAT-MON8.9K


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[^]
  Permalink  
Comments
tram7 - 2 Jun '11 - 11:49
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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 333
1 OriginalGriff 261
2 Mohammed Hameed 198
3 Mayur_Panchal 153
4 Dave Kreskowiak 125
0 Sergey Alexandrovich Kryukov 8,171
1 OriginalGriff 6,236
2 CPallini 3,482
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 2 Jun 2011
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid