Mohammad
Mohammad

Reputation: 1929

Get auto-increment id after an insert query using mysqli_multi_query

Here is the problem I need to do multiple insert into multiple tables, using mysqli_multi_query, when the id of the first insert need to be inserted into the second tables as FK, I know how to do this if they use two different connections, but how it can be done when they both are in a same query since imce using mysqli_multi_query?

%% by the way i use MySQLi along with PHP

Upvotes: 0

Views: 293

Answers (1)

user2193789
user2193789

Reputation:

Use SELECT LAST_INSERT_ID() with your second insert statement

Upvotes: 2

Related Questions