Jump to content

Php/mysql Load Data Infile


whelpton

Recommended Posts

Hey guys, thanks for reading.

 

I feel like I'm banging my head against a brick wall with this one:

 

I've got a CSV file with 9 columns and I have a MySQL table with 11 columns.

The CSV file looks like:

 

col1, col2, col3, col4, col5, col6, col7, col8, col9

 

and the MySQL table looks like:

 

col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11

 

I need to get the script to ignore the two erroneous (but required) MySQL columns.

The mysql columns that need to be ignored in the import are named: db_id & nice_date

 

This is what I have so far:

$sql = 'LOAD DATA LOCAL INFILE "../csvtemp/test.csv"
	INTO TABLE sample
		FIELDS TERMINATED BY ","
		OPTIONALLY ENCLOSED BY """"
		IGNORE 1 LINES'
;

Link to comment
https://forums.phpfreaks.com/topic/272313-phpmysql-load-data-infile/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.