1

I need to insert around 500-1000 rows into a table in mysql database.Here is the sample insert query for my table

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}>
);

And My table structure is

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'$$

please can someone help me to insert these many rows using any scripts or any other easier way ?

4

2 回答 2

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');
于 2013-09-29T18:43:12.927 回答
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

于 2013-09-29T18:52:03.727 回答