简体   繁体   中英

multiple insert sql query php

I have a table with columns ID,departmentID,val

create table departmentVal (ID INT IDENTITY(1,1), departmentID INT NOT NULL, val BIGINT)

create table departmentID (ID,departmentName)

how to do a Multiple insert of val, $count = 10k and $val = 1234900000001 to 1234900010000 into departmentVal

$i = 0;
$count = 10000;
 $va = 1234900000001;
$dptID = 1;

while  ($i < $count){
insert into departmentVal($dptID , $val);
$val++;
}

I'm seeking for better solution to do this .

CREATE PROCEDURE dorepeat(p1 INT) BEGIN SET @x = 0; REPEAT INSERT INTO your_table SELECT NULL, field1, field2; SET @x = @x + 1; UNTIL @x > p1 END REPEAT; END

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM