sql - MySQL Trigger to update a table based on changes on another table -


i've been working seemingly simple task hours no luck.

i have database, test, contains 2 tables: room , reservation.

in table room there column named reserved_status possible values of 0 , 1. room_id primary key.

in table reservation, there room_id column, refers room_id table room

basically, want create trigger, updates reserved_status 1, whenever there change in table reservation(like insert, update or delete).

the following query accepted in phpmyadmin:

delimiter $$ create trigger reserved_status_insert after insert on  reservation each row begin update  room set  room_reserved = 1  room_id = new.reservation.room_id ; end $$ delimiter ; 

however, when try insert operation, gives me error:

unknown column 'new.reservation.room_id' in 'where clause' 

i hope can provide me suitable solution, thank you...

instead of new.reservation.room_id use new.room_id, since new refers new row in reservation table.


Comments