Page 1 of 1

2 forms and 2 joined tables

Posted: Wed Nov 04, 2009 2:39 pm
by silvercover
Hi,

I have 2 related forms connected to 2 joined tables. what I want to know is that how can I code to insert submitted forms in joined tables with the same auto incremented value as a primary key for main table and foreign key for joined table? as you know, upon submission there is no auto generated primary key value to be used in other table for joining purpose.

What should I do?

Thanks in advance. :)

Re: 2 forms and 2 joined tables

Posted: Wed Nov 04, 2009 3:24 pm
by Christopher
You could create the joined record and get its key (from an autoincrement field), then use that value as the foreign key of the main table. I guess you could use that value as the primary key for the main table too, but then you would not need a foreign key field because you could join on the primary keys.

If you are not using MySQL you could use a sequence for this (or emulate it in MySQL).