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

Edited by whelpton
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.