I want make after update trigger in MySQL database,
I have a user
table, user
table is self join. I want make trigger when id
in user
is update will update at another table req_konfirmasi
and table nikah
. but I want update with another id
in user
table
ex :
|id |name
|01 |a
|011 |b
|012 |c
so b
is child from a
because b
have contain id
from a
, and if id
from a
is update so id
from b
will update too,
UPDATE user SET id = 03 WHERE id=01
so i will get new data in table like this
|id |name
|03 |a
|031 |b
|032 |b
and I want update with trigger in MySQL, and my trigger is like this
Delimiter //
CREATE TRIGGER update_id_user AFTER UPDATE ON user
FOR EACH ROW
BEGIN
SELECT RIGHT(id,2) id_child from user where id like 'OLD.id%'
IF count(id_child) >= 0 THEN
UPDATE user SET id = CONCAT(NEW.id,id_child) WHERE id like 'OLD.id%'
END IF;
END;
End Delimiter //
but it's just update in req_konfirmasi
and nikah
table. the childs id is not update, please help me for my problem