2013-09-29 17 views
1

我需要圍繞500-1000行插入在MySQL database.Here一個表樣品插入查詢我的表需要對MySQL的表中插入多行的任何腳本/技術

INSERT INTO `jtbillingtest`.`at_user` 
(`clientGuid`, 
`clientFirstName`, 
`clientMiddleName`, 
`clientLastName`, 
`gender`, 
`clientAddress`, 
`clientMobileNumber`, 
`clientEmailID`, 
`clientTypeCode`, 
`active`) 
VALUES 
(
<{clientGuid: }>, 
<{clientFirstName: }>, 
<{clientMiddleName: }>, 
<{clientLastName: }>, 
<{gender: }>, 
<{clientAddress: }>, 
<{clientMobileNumber: }>, 
<{clientEmailID: }>, 
<{clientTypeCode: }>, 
<{active: Yes}> 
); 

和我的表結構

CREATE TABLE `at_user` (
    `clientGuid` int(11) NOT NULL AUTO_INCREMENT, 
    `clientFirstName` varchar(45) DEFAULT NULL, 
    `clientMiddleName` varchar(45) DEFAULT NULL, 
    `clientLastName` varchar(45) DEFAULT NULL, 
    `gender` varchar(10) DEFAULT NULL, 
    `clientAddress` varchar(45) DEFAULT NULL, 
    `clientMobileNumber` varchar(45) NOT NULL, 
    `clientEmailID` varchar(45) DEFAULT NULL, 
    `clientTypeCode` varchar(2) DEFAULT NULL COMMENT 'Client Type code will determine whether it is a sales customer ,purchase customer ,employee or store owner.', 
    `active` varchar(45) NOT NULL DEFAULT 'Yes', 
    PRIMARY KEY (`clientGuid`), 
    UNIQUE KEY `UK_CLIENTMNILENUMBER` (`clientMobileNumber`), 
    UNIQUE KEY `clientGuid_UNIQUE` (`clientGuid`), 
    UNIQUE KEY `UK_CLIENTEMAILID` (`clientEmailID`), 
    KEY `IX_CLIENTGUID` (`clientGuid`) 
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COMMENT='THis Table is used to store the user details'$$ 

請能有人幫我插入使用任何腳本或任何其他更簡單的方法,這些多少行?

+0

看看是否[this](http:// stacko verflow.com/a/3952302/1438393)回答有幫助。 –

回答

1

用以下鏈接嘗試將幫助您:

http://www.electrictoolbox.com/mysql-insert-multiple-records/

INSERT INTO example 
    (example_id, name, value, other_value) 
VALUES 
    (100, 'Name 1', 'Value 1', 'Other 1'), 
    (101, 'Name 2', 'Value 2', 'Other 2'), 
    (102, 'Name 3', 'Value 3', 'Other 3'), 
    (103, 'Name 4', 'Value 4', 'Other 4'); 
+4

儘管可以在SO上發佈鏈接,但鼓勵您在自己的答案中包含該鏈接下找到的答案的肉,因爲鏈接可能過期/消失,如果沒有,這會使您的答案失效包括要點。另見[_在FAQ中爲鏈接_提供上下文](http://stackoverflow.com/help/how-to-answer) – Wrikken

+0

好吧,你是對的。 –

0

這將是一個PHP腳本的總體思路

for($i=0;$i<count($numrows);$i++){ 

    $sql_query = "INSERT INTO table (column1, column2 column3) VALUES ('$value1[$i]','$value2[$i]','$value3[$i]')"; 
} 

如果你能得到數據到php