i have that code from a trigger i use in one of my log tables,
** that code is updating the Child_Log table but i need to take somehow the Parent_Log PK as FK to Child_Log table after a new insert in Child_Log table.
and i want to implement it with some code like that:
any idea with the mysql query structrure?
Code:
Delimiter $$
/* Trigger for INSERT */
CREATE TRIGGER Algae_Survey_Species_Log_Insert AFTER INSERT ON Algae_Survey_Species FOR EACH ROW BEGIN
DECLARE N TIMESTAMP;
SET N = now();
INSERT INTO Algae_Survey_Species_Log(FK_Algae_Surveys_Log_ID,Action,Action_Start_Date,SurveySpecies_ID,Survey_ID,Algae,Quantity,Family)
VALUES (XXX the value we must take goes here,'CREATE', N, NEW.SurveySpecies_ID,NEW.Survey_ID,NEW.Algae,NEW.Quantity,NEW.Family);
END;
and i want to implement it with some code like that:
Code:
UPDATE child_log LEFT JOIN parent_log ON parent_log.original_pk = child_log.parent_fk AS pl SET(log_pk...) VALUE (pl.id...)
any idea with the mysql query structrure?