I am importing a CVS file for MySQL. I have two columns: one quantidade
and the other as data
. I am trying to convert to the MySQL default. In the database this column is as decimal
and date
. It is importing all the log, except that these two fields are being saved with 0
in quantidade
and null
as date. I'm wrong about the conversion and not what.
CSV file
nome do material;03B;BC 03;800000235213364;14,000;22/06/2017
nome do material;03B;BC 03;800000235213355;14,000;22/06/2017
nome do material;03B;BC 03;800000235213358;14,000;22/06/2017
nome do material;03B;BC 03;800000235213353;14,000;22/06/2017
Code
mysql_query("LOAD DATA LOCAL INFILE 'C:/wamp/www/transbordo-sap/estoque/Estoque.csv'
INTO TABLE deposito FIELDS TERMINATED BY ';'
OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
(Material,Tipo,Posicao,HU,@Qtdd,@Data)
SET Qtdd = REPLACE(REPLACE('@Qtdd', '.', ''), ',', '.'),
Data = STR_TO_DATE(@Data,'%Y-%m-%d')")or die (mysql_error());