Jump to content

Load Data Infile


computermax2328

Recommended Posts

I am actually going to piggy back onto this topic. Take a look at this query that I wrote out.

 

$sql = "LOAD DATA LOCAL INFILE '$location' INTO TABLE test FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (firstname, lastname, rank, era)";

 

In my database I am getting quotation marks around firstname and lastname and no value for rank and era. I am uploading a comma delimited CSV.

 

Thanks,

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

I am actually going to piggy back onto this topic. Take a look at this query that I wrote out.

 

$sql = "LOAD DATA LOCAL INFILE '$location' INTO TABLE test FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (firstname, lastname, rank, era)";

 

In my database I am getting quotation marks around firstname and lastname and no value for rank and era. I am uploading a comma delimited CSV.

 

Thanks,

 

I'm not too sure what you're question is...?

Link to comment
https://forums.phpfreaks.com/topic/269957-load-data-infile/#findComment-1387945
Share on other sites

Load data local infile syntax. If your fields are quoted in the CSV, you should be using ENCLOSED BY also. This would make your query:

$sql = "LOAD DATA LOCAL INFILE '$location' INTO TABLE test FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n' (firstname, lastname, rank, era)";

Link to comment
https://forums.phpfreaks.com/topic/269957-load-data-infile/#findComment-1388023
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.