0
mysql_query( "INSERT INTO users(email, password) VALUES ('$email','$password')" ); $user_id = mysql_insert_id( ); mysql_query( "INSERT INTO business_details ( business_id, name, address, city, state, country, pincode) VALUES ('$category','$business_name', '$business_address', '$city', '$state', '$country', '$pincode')" ); $idB = mysql_insert_id( ); mysql_query( "INSERT INTO user_profiles (name, phone, user_id, business_details_id) VALUES ('$person_name', '$phone_number', '$user_id', '$idB')" ); 

What will be the best way to insert all queries in one? Is it possible?

3
  • possible duplicate of sql - insert into multiple tables in one query Commented Apr 23, 2015 at 6:38
  • If you want the last ids then run the queries separately. Commented Apr 23, 2015 at 6:39
  • How can i fetch last_insert_id of each, from your ref? Commented Apr 23, 2015 at 6:39

2 Answers 2

1

No, it isn't supported in MySQL - only Oracle can do it.

Sign up to request clarification or add additional context in comments.

Comments

0

MySQL doesn't support multi-table insertion in a single INSERT statement

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.