hi i have created a trigger which i want to update a table field when insertion in another field occurs.but i don,t know how should it know that its updating the same user row who is inserting here is some code and database senerio
--> admin_reg_abr
'id course_limit username
10 0 ahmad '
note: id is primry key
--> abroad_course
'id uni_id username
1 10 ahmad'
note: uni_id is foriegn key or same as id in admin_reg_abr.
i write the following code for trigger:
DROP TRIGGER IF EXISTS ahmad.AI_course_each//
CREATE TRIGGER ahmad.AI_course_each AFTER INSERT ON ahmad.abroad_course FOR EACH ROW BEGIN
UPDATE admin_reg_abr SET admin_reg_abr.course_limit = admin_reg_abr.course_limit + 1 WHERE admin_reg_abr.id = new.id; END //
i want to update the same id how insert in the table but its not working.