0

Is it possible to INSERT INTO multiple tables for this?

SELECT first_name, last_name, feet, inche, weight, dob, college, pob, experience, cy, py
FROM player 
INNER JOIN attribute ON player.pid = attribute.pid
INNER JOIN history ON player.pid = history.pid
INNER JOIN salary ON player.pid = salary.pid

How do I join the tables for:

if(!($stmt = $mysqli->prepare("INSERT INTO player(first_name, last_name) VALUES (?, ?)"))){
   echo "Prepare for player failed: "  . $stmt->errno . " " . $stmt->error;
}
if(!($stmt->bind_param("ss", $_POST['first_name'],$_POST['last_name']))){
    echo "Bind failed: "  . $stmt->errno . " " . $stmt->error;
}
4
  • MySQL doesn't support multi-table insertion in a single INSERT statement Commented Jun 4, 2014 at 5:18
  • INSERT can happen only in one table at a time. You have to write multiple insert statement for inserting into more than one table. Commented Jun 4, 2014 at 5:18
  • Put a ; between insert statements, then it's kind of like one? Commented Jun 4, 2014 at 5:20
  • first your select is wrong! and secondly for inserting multiple entries you need to make an array and then pull it in one loop Commented Jun 4, 2014 at 5:28

1 Answer 1

1

MySQL doesn’t support insert into multiple tables via single insert statement, I believe Oracle is only support it.

But you can use a Transaction to make sure all insert statements execute via single transaction.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.