Using LOAD DATA LOCAL INFILE

In PHP, can I use LOAD DATA LOCAL INFILE to import a CSV file with one column into a table with 3 columns?
I want the data from the CSV file to go into the middle column (partnum) in the table.
Schema for table:
CREATE TABLE `partnumbers` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`partnum` VARCHAR(50) NULL DEFAULT NULL,
	`webflis` TINYINT(10) NULL DEFAULT NULL,
	INDEX `Index 1` (`id`),
	INDEX `Index 2` (`partnum`, `webflis`)
)
COLLATE='latin1_swedish_ci'
ENGINE=MyISAM
ROW_FORMAT=DEFAULT

Open in new window


Sample data:
PART_NUMBER
1813R
632440
069-00200
92D24-3
83D55-1
88060-4A
714708
2882

Open in new window


Tried this but it doesn't enter the partnum value:
LOAD DATA LOCAL INFILE "c:/wamp/www/parts/Parts_Export9.csv"  INTO TABLE partnumbers IGNORE 1 LINES (@dummy, partnum, @dummy2)

Open in new window


Can this be done or do I have to use fgetcsv?
LVL 26
Eddie ShipmanAll-around developerAsked:
Who is Participating?
 
Eddie ShipmanConnect With a Mentor All-around developerAuthor Commented:
Nevermind.
Here is the solution:

LOAD DATA LOCAL INFILE "c:/wamp/www/parts/Parts_Export9.csv"
INTO TABLE partnumbers 
IGNORE 1 LINES 
(@var1)
SET partnum=@var1;

Open in new window

0
 
Eddie ShipmanAll-around developerAuthor Commented:
Found solution on my own
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.