is there a way to link two mysql tables so that a query to update one table will automatically add an entry to another table, for instance. whenever I update the radcheck.UserName
table it will automatically add the same entry to userinfo.username
(adding any default values as the entries are added)?
CREATE TRIGGER table_name
AFTER INSERT ON table
FOR EACH ROW BEGIN
IF NEW.deleted THEN
SET @changetype = 'DELETE';
ELSE
SET @changetype = 'NEW';
END IF;
INSERT INTO audit (table_id, changetype) VALUES (NEW.id, @changetype);
END$$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.