I'm using MySQL's LOAD DATA LOCAL INFILE SQL statement to load data from a CSV file into an existing database table.
Here is an example SQL statement:
LOAD DATA LOCAL INFILE 'file.csv' INTO TABLE my_table
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '
'
(name, address, dateOfBirth)
The third column in the CSV that maps to the dateOfBirth field currently has the date in the following format:
14-Feb-10
How can I modify the above SQL statement to format the date into MySQL's date format i.e. 2010-02-14
?
I know how to convert a string date when using normal INSERT syntax using:
STR_TO_DATE('14-Feb-10', '%d-%b-%y')
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…