DELIMITER //
CREATE TRIGGER check_alert_trg
AFTER INSERT
ON main FOR EACH ROW
BEGIN
DECLARE check_id INT;
SELECT id INTO check_id from check where check.number=NEW.number and check.code=NEW.code;
if (check_id is not null) THEN
INSERT INTO check_alert VALUES(NEW.id,check_id,CURRENT_TIMESTAMP);
end IF;
END
//
DELIMITER;