I am importing csv file into mysql using load data. My load data command is as mentioned below.
load data local infile 'D:/mydata.csv' into table mydb.mydata
fields terminated by ','
enclosed by '"'
lines terminated by '\r\n'
ignore 1 lines
(SrNo,SourceFrom,@var_updated,Title,First_Name,Middle_Name,Last_Name,Designation,Company_Name,@var_dob,Office_Mobile_No)
set updated = str_to_date(@var_updated,'%Y-%m-%d'), dob = str_to_date(@var_dob, '%Y-%m-%d');
I am getting different values in my "Updated" and "DOB" columns. Such values are different in my .csv file.
First image is from mysql workbench while another is of csv.
Also, I sat "office_mobile_no" column's format to 'number' in csv. But its showing number like this.
When I double click on it, then only it shows the real number like 9875461234. It imports the same in mysql too. How do I get original number in a specific column? Also why my imported date values are differ from csv's date columns?
A couple of points that I can see:
set updated = str_to_date(@var_updated,'%Y-%m-%d')
to
set updated = str_to_date(@var_updated,'%d-%m-%Y')
And the same for DOB field as well, assuming your CSV has that in the same format.