whelpton Posted December 23, 2012 Share Posted December 23, 2012 (edited) 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 December 23, 2012 by whelpton Quote Link to comment https://forums.phpfreaks.com/topic/272313-phpmysql-load-data-infile/ Share on other sites More sharing options...
Barand Posted December 23, 2012 Share Posted December 23, 2012 You can specify the cols to be loaded (scroll about halfway down this link) http://dev.mysql.com/doc/refman/5.6/en/load-data.html Quote Link to comment https://forums.phpfreaks.com/topic/272313-phpmysql-load-data-infile/#findComment-1401046 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.