Insert into multiple tables

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
nsarsalan
Posts: 1
Joined: 2015-08-12 11:16

Insert into multiple tables

Post by nsarsalan » 2015-08-12 12:08

Hi dear

I have one table
entries
another table
details
Now when I add entry I want to add two records into
details
table

ID of
entries
should store into
details
tables' 2nd column which is fk

Please advice

lucicd
Posts: 13
Joined: 2015-09-16 08:48

Re: Insert into multiple tables

Post by lucicd » 2015-09-20 06:12

If I may suggest that you use MySQL trigger. Something like this:

Code: Select all

CREATE TRIGGER add_details AFTER INSERT ON entries
  FOR EACH ROW
  BEGIN
    INSERT INTO details SET entries_id = NEW.id, etc...;
    etc...
  END;

Post Reply