When executing multiple MySQl statements, is there a way I can can get the last inserted id and insert it in another table? For example if a primary key is a foreign key in my second table.
Table one
user_id | username|
-------------------
1 |userone
2 |usertwo
3 |userthree
Table 2
contact_id | user_id | contact_name
------------------------------------
12 | 1 | John Doe
18 | 2 | Jane Doe
23 | 3 | An other
Basically I want to insert on two tables at the same time, insert on table one then use the value to insert on table two rather than insert on table one then on table two.