问题
i have a csv file with one of the column as format: 20131231 (eg. 2013-12-31)
i've a mysql table with field column 'date' with format int(10).
i want to use phpmyadmin to import the csv file so that the mysql table can accurately capture the date. Pls advise how to do so, thanks.
回答1:
I would first create a temporary column to hold the date string, then import the csv as it is, then use the following SQL statement:
UPDATE tablename SET actual_date_column = STR_TO_DATE(temp_date_column, '%Y/%m/%d');
More info on STR_TO_DATE()
Hope that helps!
来源:https://stackoverflow.com/questions/17483436/phpmyadmin-import-csv-with-difficult-on-date-format