|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Trigger which changes values in another table
Hey all,
I'd like to create a trigger when, upon inserting a record in one table (Reservation), changes the value of an attribute in another table (Flight). I want to do this so that when a flight reservation is made, I can decrement the number of seats available for that particular flight. What I've come up with so far is: CREATE TRIGGER decr_on_reserve AFTER INSERT ON Reservation FOR EACH ROW BEGIN UPDATE Flight SET Flight.available = Flight.available - 1 WHERE Flight.fid = NEW.rfid; END; That is not correct, but I've googled around and haven't found any useful resources yet. Any ideas? |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Trigger which changes values in another table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|