0
我正在将数据从csv
导入到MySQL
表。我需要将日期格式从String
转换为Date
。 从开始格式压轴格式:MySQL导入CSV转换日期格式
Mon Feb 04 00:00:00 UTC 2011 ---> 2011-02-04 00:00:00
我已经成功地做到了:
select str_to_date('Mon Feb 04 00:00:00 UTC 2011', '%a %b %d %k:%i:%s UTC %Y');
现在我正在写剧本,从csv
做所有的进口中,有2列用要转换的日期,但我在set
零件上遇到MySQL
语法异常。
我SQL
脚本:
load data local infile 'movimento.csv' into table movimento
fields terminated by ',' lines terminated by '\n'
(id, anno, creditore, @data_pag, @data_spost, descrizione)
set data_pagamento = str_to_date(@data_pag, '%a %b %d %k:%i:%s UTC %Y')
set data_spostamento = str_to_date(@data_spost, '%a %b %d %k:%i:%s UTC %Y')
show warnings;
我卡上的set
部分的语法异常。错误:
错误1064(42000):您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册,以便在'set data_spostamento = str_to_date(@data_spost,'%a%b%d%k:%i:%s UTC%Y')附近使用正确的语法。 show'at line 5 >
什么是正确的语法?