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?