MySQL Forums
Forum List  »  Newbie

Re: Triggers on two tables to get Primary Keys (Auto Increment) into third linking table
Posted by: Vladimir Velan
Date: February 23, 2016 06:31AM

Thank you for your reply, What I have used is below:

mysqli_multi_query($con,"
START TRANSACTION;
INSERT INTO author(AuthorTitle, F_Name, L_Name, Email, Contact)
VALUES('$AuthorTitle','$F_Name','$L_Name','$Email','$Contactauthor');
SET @AuthorId = LAST_INSERT_ID();
INSERT INTO study(Title) VALUES('$Title');
SET @StudyId = LAST_INSERT_ID();
INSERT INTO casestudy (AuthorId, StudyId, Submitted)
VALUES(@AuthorId, @StudyId, NOW());
COMMIT;
");

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.