0

In order to run a query for database MySQL, we are using mysqli_query. Then, for running a query for database Oracle, we are using oci_execute.

When we wish to running multiple query for database MySQL, we are using mysqli_multi_query. Example as below:-

$mysqliconn = mysqliconn();         //mysqli connection
$sql = '
INSERT INTO TABLE VALUES();
INSERT INTO TABLE VALUES();
INSERT INTO TABLE VALUES();
INSERT INTO TABLE VALUES();
';
if(mysqli_multi_query($mysqliconn, $sql)) {
    echo 'Success';
}

My Question is if there anyone of you whom can come out with the most simplest solution to run multiple inserting values into the database table using one command execution.

5
  • There's a similar question here: stackoverflow.com/questions/2449132/… Would that help? Commented Sep 17, 2019 at 9:16
  • @Hugo nope, the question is for Oracle. Commented Sep 17, 2019 at 9:20
  • Mimi in MySQL the way you've shown us isn't the best way to insert multiple entries. You should rather use INSERT INTO table VALUES (), (), (); Commented Sep 17, 2019 at 9:21
  • By the way, if your question is about Oracle, don't tag other RDBMS Commented Sep 17, 2019 at 9:25
  • @Hugo, my question is for Oracle. I just give an example in MySQL. Anyway, thanks for answering. Commented Sep 18, 2019 at 2:36

2 Answers 2

0

Oracle has an INSERT ALL statement for that. Otherwise you could just loop in your code and execute it n times.

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

1 Comment

INSERT ALL statement is really works. Thank you for giving me a new knowledge.
-1
$sql = '
INSERT INTO TABLE abc VALUES(123,'xyz'),(456,'def'),(789,'qwe');
';

I suggest that using support library ^^

1 Comment

this doesn't work in Oracle

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.