Insert primary and foreign key at "same time" SQL

Asked

Viewed 42 times

0

Suppose two tables "company" and "employee" within employee has a key Foreign for the company

When the user goes to create a new company he answers a form that in this form he adds the name of the employees

what I want to do : When he clicks 'Ubmit', create the company and get her ID. Then with the ID create the employees and put this ID in the foreign key

How do I get this ID ? Do I need to do a database query or is there an easier way ? Because it is generated automatically by the bank, with the function of auto increment of it. I do not pass manually

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.